当前位置:网站首页>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;
}
边栏推荐
- 远程升级怕截胡?详解FOTA安全升级
- A problem and solution of recording QT memory leakage
- Acwing 4300. Two operations
- Daily question - longest substring without repeated characters
- Mysql database (I)
- High precision subtraction
- [to be continued] [UE4 notes] L3 import resources and project migration
- 质量体系建设之路的分分合合
- 剑指 Offer 05. 替换空格
- 全国中职网络安全B模块之国赛题远程代码执行渗透测试 //PHPstudy的后门漏洞分析
猜你喜欢
[turn]: OSGi specification in simple terms
剑指 Offer 53 - I. 在排序数组中查找数字 I
[to be continued] [UE4 notes] L1 create and configure items
Sword finger offer 04 Search in two-dimensional array
Palindrome (csp-s-2021-palin) solution
[interval problem] 435 Non overlapping interval
[turn to] MySQL operation practice (III): table connection
Pointnet++学习
On-off and on-off of quality system construction
YOLOv5添加注意力机制
随机推荐
Binary search basis
Reader writer model
浅谈JVM(面试常考)
Educational Codeforces Round 107 (Rated for Div. 2) E. Colorings and Dominoes
YOLOv5-Shufflenetv2
Download xftp7 and xshell7 (official website)
Zheng Qing 21 ACM is fun. (3) part of the problem solution and summary
Yolov5 ajouter un mécanisme d'attention
Sword finger offer 06 Print linked list from beginning to end
Control Unit 控制部件
Support multi-mode polymorphic gbase 8C database continuous innovation and heavy upgrade
kubeadm系列-02-kubelet的配置和启动
Kubedm series-00-overview
Solon Logging 插件的添加器级别控制和日志器的级别控制
Under the national teacher qualification certificate in the first half of 2022
[turn to] MySQL operation practice (III): table connection
Solution to the palindrome string (Luogu p5041 haoi2009)
kubeadm系列-01-preflight究竟有多少check
Developing desktop applications with electron
Palindrome (csp-s-2021-palin) solution