QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#28351 | #2353. Maharajas are Going Home | Wu_Ren | WA | 360ms | 23528kb | C++17 | 1.3kb | 2022-04-13 18:55:17 | 2022-04-29 09:39:45 |
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);
pair<int,int>tp={2*n,2*n};
for(int j=0;j<y[i];j++) if(sg[x[i]][j]==w) tp=min(tp,{x[i]+1,j+1});
for(int j=0;j<x[i];j++) if(sg[j][y[i]]==w) tp=min(tp,{j+1,y[i]+1});
for(int j=1;j<=x[i]&&j<=y[i];j++) if(sg[x[i]-j][y[i]-j]==w) tp=min(tp,{x[i]-j+1,y[i]-j+1});
if(x[i]>1&&y[i]>0&&sg[x[i]-2][y[i]-1]==w) tp=min(tp,{x[i]-1,y[i]});
if(x[i]>0&&y[i]>1&&sg[x[i]-1][y[i]-2]==w) tp=min(tp,{x[i],y[i]-1});
printf("%d %d\n",tp.first,tp.second);
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: 360ms
memory: 23444kb
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: 358ms
memory: 23360kb
input:
1 1 1 1
output:
-1 -1 -1
result:
ok single line: '-1 -1 -1'
Test #3:
score: -100
Wrong Answer
time: 346ms
memory: 23528kb
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 2 1 1 1 1 1 1 1 2 2 1 2 2 -1 -1 -1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 -1 -1 -1 1 2 2 1 1 1 -1 -1 -1 1 2 2 1 2 2 -1 -1 -1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 1 2 2 1 1 1 1 1 1 -1 -1 -1 1 2 2 1 2 2 1 2 2 1 2 2 1 1 1 1 1 1 1 2 2 1 2 2 1 1 1 1 2 2 1 1 1 1 1 1 1 1 1 1 1 1 -1 -1 -1 1 2 2 1 2 2 1 1 1 ...
result:
wrong answer 3rd lines differ - expected: '1 2 4', found: '1 2 2'