【#文档大全网# 导语】以下是®文档大全网的小编为您整理的《迷妹的活动代码》,欢迎阅读!
#include #include void read(int &x) {
x=0;bool f=0;
register char ch=getchar();
for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=1; for(; isdigit(ch);ch=getchar()) x=x*10+ch-'0'; x=f?(~x)+1:x; }
int n,q,sum[100005][4]; int main() {
freopen("fans.in","r",stdin);freopen("fans.out","w",stdout); read(n);read(q); for(int opt,i=1;i<=n;i++) {
read(opt); if(opt==1) {
sum[i][1]=sum[i-1][1]+1; sum[i][2]=sum[i-1][2]; sum[i][3]=sum[i-1][3]; }
else if(opt==2) {
sum[i][1]=sum[i-1][1]; sum[i][2]=sum[i-1][2]+1; sum[i][3]=sum[i-1][3]; }
else {
sum[i][1]=sum[i-1][1]; sum[i][2]=sum[i-1][2]; sum[i][3]=sum[i-1][3]+1; } }
for(int x,y;q--;) {
read(x);read(y);
printf("%d %d %d\n",sum[y][1]-sum[x-1][1],sum[y][2]-sum[x-1][2],sum[y][3]-sum[x-1][3]); } return 0; }
本文来源:https://www.wddqxz.cn/0af7ea916629647d27284b73f242336c1fb93046.html