QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#28350 | #2353. Maharajas are Going Home | Wu_Ren | WA | 348ms | 23576kb | C++17 | 1.3kb | 2022-04-13 18:51:47 | 2022-04-29 09:39:40 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int n=2000;
bitset<4001>r[2010],c[2010],h[4010],*d,tp;
int sg[2010][2010],x[20],y[20];
void sol(){
scanf("%d",&n);
int ans=0;
for(int i=1;i<=n;i++) scanf("%d%d",&x[i],&y[i]),x[i]--,y[i]--,ans^=sg[x[i]][y[i]];
if(ans){
for(int i=1;i<=n;i++) if(sg[x[i]][y[i]]>(ans^sg[x[i]][y[i]])){
int w=ans^sg[x[i]][y[i]];
printf("%d ",i);
bool fl=1;
for(int j=0;j<y[i]&&fl;j++) if(sg[x[i]][j]==w) printf("%d %d\n",x[i]+1,j+1),fl=0;
for(int j=0;j<x[i]&&fl;j++) if(sg[j][y[i]]==w) printf("%d %d\n",j+1,y[i]+1),fl=0;
for(int j=1;j<=x[i]&&j<=y[i]&&fl;j++) if(sg[x[i]-j][y[i]-j]==w) printf("%d %d\n",x[i]-j+1,y[i]-j+1),fl=0;
if(fl&&x[i]>1&&y[i]>0&&sg[x[i]-2][y[i]-1]==w) printf("%d %d\n",x[i]-1,y[i]),fl=0;
if(fl&&x[i]>0&&y[i]>1&&sg[x[i]-1][y[i]-2]==w) printf("%d %d\n",x[i],y[i]-1),fl=0;
assert(!fl);
break;
}
}
else puts("-1 -1 -1");
}
void init(int n){
d=h+n;
for(int i=0;i<n;i++){
r[i].set(),c[i].set();
}
for(int i=-n+1;i<n;i++) d[i].set();
for(int i=0;i<n;i++) for(int j=0;j<n;j++){
tp=r[i]&c[j]&d[i-j];
if(i>1&&j>0) tp.set(sg[i-2][j-1],0);
if(i>0&&j>1) tp.set(sg[i-1][j-2],0);
sg[i][j]=tp._Find_first();
r[i].set(sg[i][j],0),c[j].set(sg[i][j],0),d[i-j].set(sg[i][j],0);
}
}
int main(){
init(2000);
int T;
scanf("%d",&T);
while(T--) sol();
}
详细
Test #1:
score: 100
Accepted
time: 347ms
memory: 23508kb
input:
3 5 2 3 3 2 3 3 3 3 3 3 1 2 4 2 1 1 3 2
output:
3 1 1 -1 -1 -1 2 1 1
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 348ms
memory: 23452kb
input:
1 1 1 1
output:
-1 -1 -1
result:
ok single line: '-1 -1 -1'
Test #3:
score: -100
Wrong Answer
time: 347ms
memory: 23576kb
input:
100 1 5 5 1 1 5 1 5 4 1 4 4 1 2 2 1 5 3 1 4 5 1 2 4 1 4 1 1 3 2 1 3 2 1 1 4 1 2 5 1 4 2 1 5 3 1 5 5 1 4 2 1 3 4 1 3 4 1 4 2 1 3 1 1 1 5 1 1 4 1 4 1 1 4 5 1 2 5 1 5 1 1 4 1 1 2 4 1 2 5 1 3 4 1 2 5 1 5 4 1 4 4 1 2 3 1 3 4 1 5 4 1 1 3 1 3 4 1 1 5 1 5 1 1 2 3 1 3 1 1 1 1 1 5 2 1 2 5 1 1 4 1 3 3 1 4 3 1 ...
output:
1 1 1 1 1 1 1 2 4 1 4 2 1 1 1 1 4 2 1 4 2 -1 -1 -1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 4 -1 -1 -1 1 4 2 1 1 1 -1 -1 -1 1 2 4 1 2 4 -1 -1 -1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 2 1 2 4 1 1 1 1 1 1 -1 -1 -1 1 2 4 1 2 4 1 2 4 1 2 4 1 4 2 1 1 1 1 2 4 1 2 4 1 1 1 1 2 4 1 1 1 1 1 1 1 1 1 1 1 1 -1 -1 -1 1 4 2 1 2 4 1 1 1 ...
result:
wrong answer 4th lines differ - expected: '1 1 1', found: '1 4 2'