QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#137288#2353. Maharajas are Going HomeDelay_for_five_minutes#WA 223ms22264kbC++202.5kb2023-08-10 09:37:012023-08-10 09:37:04

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-10 09:37:04]
  • 评测
  • 测评结果:WA
  • 用时:223ms
  • 内存:22264kb
  • [2023-08-10 09:37:01]
  • 提交

answer

#include<bits/stdc++.h>
#define maxn 2005
#define N 2000
#define n0 3000
std::bitset<n0> r[maxn],w[maxn],d[maxn*2];
int sg[maxn][maxn];
void presolve() {
    for(int i=0;i<=N;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;
    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+2000];
            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);
            r[i][val] = 0;
            w[j][val] = 0;
            d[i-j+2000][val] = 0;
            sg[i][j] = val;
        }
    }
}
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();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 198ms
memory: 22236kb

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: 198ms
memory: 22188kb

input:

1
1
1 1

output:

-1 -1 -1

result:

ok single line: '-1 -1 -1'

Test #3:

score: -100
Wrong Answer
time: 223ms
memory: 22264kb

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 0 1
1 2 4
1 2 4
1 1 3
1 2 4
1 1 5
1 1 1
1 0 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'