当前位置:网站首页>Fried chicken nuggets and fifa22
Fried chicken nuggets and fifa22
2022-07-05 05:31:00 【solemntee】
Consider doubling
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int st[200005][3][20];
char s[200005];
int main()
{
int n,q;
scanf("%d%d",&n,&q);
scanf("%s",s+1);
for(int i=1;i<=n;i++)
for(int j=0;j<=2;j++)
{
if(s[i]=='W')st[i][j][0]=1;
else if(s[i]=='L')
{
if(j==0)st[i][j][0]=0;
else st[i][j][0]=-1;
}
else st[i][j][0]=0;
}
for(int j=1;j<=19;j++)
for(int i=1;i<=n;i++)
for(int k=0;k<=2;k++)
{
int t=((k+st[i][k][j-1])%3+3)%3;
if(i+(1<<j)<=n+1)
{
st[i][k][j]=st[i][k][j-1]+st[i+(1<<(j-1))][t][j-1];
}
}
for(int i=1;i<=q;i++)
{
int l,r,s;
scanf("%d%d%d",&l,&r,&s);
int nowpos=l;
while(nowpos<r+1)
{
// cout<<nowpos<<endl;
int ts=(s%3+3)%3;
for(int j=19;j>=0;j--)
{
if(nowpos+(1<<j)<=r+1)
{
s+=st[nowpos][ts][j];
nowpos=nowpos+(1<<j);
break;
}
}
}
printf("%d\n",s);
}
return 0;
}
边栏推荐
猜你喜欢

Sword finger offer 35 Replication of complex linked list

Double pointer Foundation

Sword finger offer 58 - ii Rotate string left

YOLOv5添加注意力機制

剑指 Offer 05. 替换空格

The present is a gift from heaven -- a film review of the journey of the soul

【Jailhouse 文章】Jailhouse Hypervisor
![[turn]: OSGi specification in simple terms](/img/54/d73a8d3e375dfe430c2eca39617b9c.png)
[turn]: OSGi specification in simple terms

剑指 Offer 06.从头到尾打印链表

Sword finger offer 09 Implementing queues with two stacks
随机推荐
[speed pointer] 142 circular linked list II
Sword finger offer 53 - ii Missing numbers from 0 to n-1
Educational Codeforces Round 107 (Rated for Div. 2) E. Colorings and Dominoes
数仓项目的集群脚本
A preliminary study of sdei - see the essence through transactions
Detailed explanation of expression (csp-j 2021 expr) topic
Haut OJ 2021 freshmen week II reflection summary
每日一题-无重复字符的最长子串
[sum of two numbers] 169 sum of two numbers II - enter an ordered array
剑指 Offer 53 - I. 在排序数组中查找数字 I
发现一个很好的 Solon 框架试手的教学视频(Solon,轻量级应用开发框架)
Palindrome (csp-s-2021-palin) solution
[depth first search] 695 Maximum area of the island
SDEI初探-透过事务看本质
YOLOv5-Shufflenetv2
Haut OJ 1221: a tired day
Talking about JVM (frequent interview)
Haut OJ 1218: maximum continuous sub segment sum
Support multi-mode polymorphic gbase 8C database continuous innovation and heavy upgrade
SAP-修改系统表数据的方法