QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#445935 | #8526. Polygon II | grass8cow | WA | 1ms | 6152kb | C++17 | 1.1kb | 2024-06-16 17:28:53 | 2024-06-16 17:28:54 |
Judging History
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;
}
Details
Tip: Click on the bar to expand more detailed information
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'