当前位置:网站首页>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;
}
边栏推荐
- Zzulioj 1673: b: clever characters???
- Little known skills of Task Manager
- 数仓项目的集群脚本
- Haut OJ 1352: string of choice
- 浅谈JVM(面试常考)
- Sword finger offer 04 Search in two-dimensional array
- 卷积神经网络——卷积层
- Sword finger offer 53 - ii Missing numbers from 0 to n-1
- Fragment addition failed error lookup
- 动漫评分数据分析与可视化 与 IT行业招聘数据分析与可视化
猜你喜欢
YOLOv5-Shufflenetv2
对象的序列化
【Jailhouse 文章】Jailhouse Hypervisor
【Jailhouse 文章】Look Mum, no VM Exits
Double pointer Foundation
Acwing 4300. Two operations
Gbase database helps the development of digital finance in the Bay Area
Chapter 6 data flow modeling - after class exercises
[depth first search] 695 Maximum area of the island
挂起等待锁 vs 自旋锁(两者的使用场合)
随机推荐
The number of enclaves
Add level control and logger level control of Solon logging plug-in
ssh免密登录设置及使用脚本进行ssh登录并执行指令
卷积神经网络——卷积层
Zheng Qing 21 ACM is fun. (3) part of the problem solution and summary
SAP method of modifying system table data
[turn to] MySQL operation practice (I): Keywords & functions
剑指 Offer 35.复杂链表的复制
剑指 Offer 53 - I. 在排序数组中查找数字 I
软件测试 -- 0 序
YOLOv5添加注意力機制
【Jailhouse 文章】Look Mum, no VM Exits
Introduction to tools in TF-A
Haut OJ 1316: sister choice buys candy III
浅谈JVM(面试常考)
远程升级怕截胡?详解FOTA安全升级
注解与反射
Fragment addition failed error lookup
Codeforces round 712 (Div. 2) d. 3-coloring (construction)
Haut OJ 1350: choice sends candy