QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#445935#8526. Polygon IIgrass8cowWA 1ms6152kbC++171.1kb2024-06-16 17:28:532024-06-16 17:28:54

Judging History

你现在查看的是最新测评结果

  • [2024-06-16 17:28:54]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:6152kb
  • [2024-06-16 17:28:53]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n,k;
int a[301000],b[301000];
char C[301000];
int M(int e){while(e>n)e-=n;while(e<=0)e+=n;return e;}
int ans,U[301000],V[300010],x,y;
deque<int>p1,p2;
void doi(){
    while(p1.front()==1){
        a[M(x+k)]=p1.back();p1.pop_back();
        x=M(x-1);p1.push_front(a[x]);
    }
    while(p2.back()==0){
        b[y]=p2.front();p2.pop_front();
        y=M(y+1);p2.push_back(b[M(y+k-1)]);
    }
}
int main(){
    scanf("%d%d%s",&n,&k,C+1);int sk=0;for(int i=1;i<=n;i++)a[i]=(C[i]=='B'),sk+=a[i];
    scanf("%s",C+1);for(int i=1;i<=n;i++)b[i]=(C[i]=='B');
    if(sk*2<n){for(int i=1;i<=n;i++)a[i]^=1,b[i]^=1;sk=n-sk;}
    x=1,y=1;
    int step=n-sk;
    for(int i=1;i<=k+1;i++)p1.push_back(a[i]);
    for(int i=1;i<=k;i++)p2.push_back(b[i]);
    while(step--){
        doi();
        ans++,U[ans]=M(x+1),V[ans]=y;
        ans++,U[ans]=x,V[ans]=y;
        p1.pop_front(),p1.push_back(1);
        p2.pop_back(),p2.push_front(0);
    }
    printf("%d\n",ans);
    for(int i=1;i<=ans;i++)printf("%d %d\n",U[i],V[i]);
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 6152kb

input:

3
0 2 0

output:

0

result:

wrong answer 1st numbers differ - expected: '166666668', found: '0'