当前位置:网站首页>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;
}
边栏推荐
- Kubedm series-00-overview
- Solon 框架如何方便获取每个请求的响应时间?
- [interval problem] 435 Non overlapping interval
- 【Jailhouse 文章】Jailhouse Hypervisor
- kubeadm系列-02-kubelet的配置和启动
- object serialization
- A misunderstanding about the console window
- Drawing dynamic 3D circle with pure C language
- Reader writer model
- [allocation problem] 135 Distribute candy
猜你喜欢
Binary search basis
质量体系建设之路的分分合合
[to be continued] [UE4 notes] L2 interface introduction
Romance of programmers on Valentine's Day
[depth first search] 695 Maximum area of the island
YOLOv5-Shufflenetv2
SAP-修改系统表数据的方法
【Jailhouse 文章】Look Mum, no VM Exits
Light a light with stm32
[to be continued] [UE4 notes] L1 create and configure items
随机推荐
游戏商城毕业设计
记录QT内存泄漏的一种问题和解决方案
质量体系建设之路的分分合合
Graduation project of game mall
剑指 Offer 09. 用两个栈实现队列
Use of room database
注解与反射
Summary of Haut OJ 2021 freshman week
[merge array] 88 merge two ordered arrays
Talking about JVM (frequent interview)
Daily question - Search two-dimensional matrix PS two-dimensional array search
Animation scoring data analysis and visualization and it industry recruitment data analysis and visualization
Solon Auth 认证框架使用演示(更简单的认证框架)
A misunderstanding about the console window
利用HashMap实现简单缓存
Sword finger offer 09 Implementing queues with two stacks
object serialization
Demonstration of using Solon auth authentication framework (simpler authentication framework)
搭建完数据库和网站后.打开app测试时候显示服务器正在维护.
Control Unit 控制部件