QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#137294 | #2353. Maharajas are Going Home | Delay_for_five_minutes# | WA | 244ms | 23544kb | C++20 | 2.6kb | 2023-08-10 09:47:28 | 2023-08-10 09:47:32 |
Judging History
answer
#include<bits/stdc++.h>
#define maxn 2005
#define N 2000
#define n0 4000
std::bitset<n0> r[maxn],w[maxn],d[maxn*2];
int sg[maxn][maxn];
void presolve() {
for(int i=0;i<=n0;i++) {
r[0][i] = 1;
}
for(int i=0;i<=N;i++) {
r[i] = r[0];
w[i] = r[0];
}
for(int i=0;i<=2*N;i++) {
d[i] = r[0];
}
d[2000][0] = 0;
r[1][0] = 0;
w[1][0] = 0;
std::bitset<n0> now;
int mx = 0;
for(int i=1;i<=N;i++) {
for(int j=1;j<=N;j++) {
if (i==1&&j==1) {
continue;
}
now = r[i] & w[j] & d[i-j+N];
if(i > 1 && j > 2) {
int p = sg[i-1][j-2];
now[p] = 0;
}
if (i > 2 && j > 1) {
int p = sg[i-2][j-1];
now[p] = 0;
}
int val = now._Find_first();
assert(val <= n0);
mx = std::max(mx,val);
r[i][val] = 0;
w[j][val] = 0;
d[i-j+2000][val] = 0;
sg[i][j] = val;
}
}
// std::cerr << mx << std::endl;
}
void solve() {
int r[20],c[20];
int k = 0,ans=0;
std::cin >> k;
for(int i=1;i<=k;i++) {
std::cin >> r[i] >> c[i];
ans ^= sg[r[i]][c[i]];
}
if (ans == 0) {
printf("-1 -1 -1\n");
return ;
}
for(int i=1;i<=k;i++) {
for(int j=1;j<=r[i];j++) {
if (!(ans ^ sg[r[i]][c[i]] ^ sg[j][c[i]])) {
printf("%d %d %d\n",i,j,c[i]);
return ;
}
}
for(int j=1;j<=c[i];j++) {
if (!(ans ^ sg[r[i]][c[i]] ^ sg[r[i]][j])) {
printf("%d %d %d\n",i,j,c[i]);
return ;
}
}
for(int j=1;j<=std::min(r[i],c[i])-1;j++) {
if (!(ans ^ sg[r[i]][c[i]] ^ sg[r[i]-j][c[i]-j])) {
printf("%d %d %d\n",i,r[i]-j,c[i]-j);
return ;
}
}
int x = r[i] - 1, y = c[i] - 2;
if (x >= 1 && y >= 1 && !(ans ^ sg[r[i]][c[i]] ^ sg[x][y])) {
printf("%d %d %d\n",i,x,y);
return ;
}
x = r[i] - 2, y = c[i] - 1;
if (x >= 1 && y >= 1 && !(ans ^ sg[r[i]][c[i]] ^ sg[x][y])) {
printf("%d %d %d\n",i,x,y);
return ;
}
}
}
int main() {
// freopen("in.txt","r",stdin);
std::ios::sync_with_stdio(0);std::cin.tie(0);
int T;
presolve();
std::cin >> T;
while(T--) {
solve();
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 238ms
memory: 23544kb
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: 244ms
memory: 23136kb
input:
1 1 1 1
output:
-1 -1 -1
result:
ok single line: '-1 -1 -1'
Test #3:
score: -100
Wrong Answer
time: 238ms
memory: 23488kb
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 5 1 2 4 1 2 4 1 1 1 1 4 2 1 2 5 -1 -1 -1 1 1 1 1 1 1 1 1 1 1 1 4 1 4 5 -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 5 1 1 4 1 1 1 1 2 5 1 4 5 1 1 1 1 1 1 -1 -1 -1 1 4 5 1 2 4 1 4 5 1 2 4 1 2 4 1 1 1 1 2 4 1 2 4 1 1 3 1 2 4 1 1 5 1 1 1 1 1 1 1 1 1 -1 -1 -1 1 4 2 1 4 5 1 1 4 ...
result:
wrong answer 2nd lines differ - expected: '1 1 1', found: '1 1 5'