QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#681861#6305. Chinese CheckerTggdbWA 4ms3652kbC++203.9kb2024-10-27 12:29:512024-10-27 12:29:53

Judging History

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

  • [2024-10-27 12:29:53]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:3652kb
  • [2024-10-27 12:29:51]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
#define ll __int128
#define ull unsigned long long
using namespace std;
pair<int,int> e[20][20][6];
int vis[25][25],bj[25][25];
int ans=0;
void dfs(int x,int y){
    for (int i=0;i<6;i++){
        int cnt=0,nowx=x,nowy=y;
        while (1){
            auto [resx,resy]=e[nowx][nowy][i];
            cnt++;
            if (vis[resx][resy]||resx==0){
                nowx=resx;
                nowy=resy;
                break;
            }
            nowx=resx;
            nowy=resy;
        }
        if (nowx==0){
            continue;
        }
        // cout<<nowx<<" "<<nowy<<" "<<cnt<<" ";

        bool flag=1;
        while (cnt--){
            auto [resx,resy]=e[nowx][nowy][i];
            nowx=resx;
            nowy=resy;
            if (vis[resx][resy]||resx==0){
                flag=0;
                break;
            }
        }
        if (nowx==0){
            continue;
        }

        if (flag&&!bj[nowx][nowy]){
            // cout<<x<<" "<<y<<" "<<nowx<<" "<<nowy<<"\n";
            bj[nowx][nowy]=1;
            ans++;
            vis[x][y]=0;
            vis[nowx][nowy]=1;
            dfs(nowx,nowy);
            vis[x][y]=1;
            vis[nowx][nowy]=0;
        }
    }
}
void paralysis(){
    ans=0;
    int n;
    cin>>n;
    memset(vis,0,sizeof(vis));

    vector<int> x(n+1),y(n+1);
    for (int i=1;i<=n;i++){
        cin>>x[i]>>y[i];
        vis[x[i]][y[i]]=1;
    }
    for (int i=1;i<=n;i++){
        memset(bj,0,sizeof(bj));
        bj[x[i]][y[i]]=1;
        dfs(x[i],y[i]);
        // cout<<"\n\n";
    }
    cout<<ans<<"\n";
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    

    for (int i=2;i<=4;i++){
        for (int j=2;j<=i;j++){
            e[i][j][0]={i-1,j-1};
            e[i-1][j-1][1]={i,j};
        }
        for (int j=1;j<i;j++){
            e[i][j][2]={i-1,j};
            e[i-1][j][3]={i,j};
        }
    }
    for (int j=6;j<=9;j++){
        e[5][j][0]={4,j-5};
        e[4][j-5][1]={5,j};
    }
    for (int j=5;j<=8;j++){
        e[5][j][2]={4,j-4};
        e[4][j-4][3]={5,j};
    }

    for (int i=6;i<=9;i++){
        for (int j=1;j<=12-(i-6);j++){
            e[i][j][0]={i-1,j};
            e[i-1][j][1]={i,j};
        }

        for (int j=1;j<=12-(i-6);j++){
            e[i][j][2]={i-1,j+1};
            e[i-1][j+1][3]={i,j};
        }
    }
    for (int i=10;i<=13;i++){
        for (int j=2;j<=9+(i-9);j++){
            e[i][j][0]={i-1,j-1};
            e[i-1][j-1][1]={i,j};
        }
        for (int j=1;j<9+(i-9);j++){
            e[i][j][2]={i-1,j};
            e[i-1][j][3]={i,j};
        }
    }
    for (int j=1;j<=4;j++){
        e[14][j][0]={13,j+4};
        e[13][j+4][1]={14,j};
    }
    for (int j=1;j<=4;j++){
        e[14][j][2]={13,j+5};
        e[13][j+5][3]={14,j};
    }

    for (int i=15;i<=17;i++){
        for (int j=1;j<=3-(i-15);j++){
            e[i][j][0]={i-1,j};
            e[i-1][j][1]={i,j};
        }
        for (int j=1;j<=3-(i-15);j++){
            e[i][j][2]={i-1,j+1};
            e[i-1][j+1][3]={i,j};
        }
    }

    for (int i=2;i<=4;i++){
        for (int j=1;j<i;j++){
            e[i][j][4]={i,j+1};
            e[i][j+1][5]={i,j};
        }
    }

    for (int i=5;i<=9;i++){
        for (int j=1;j<13-(i-5);j++){
            e[i][j][4]={i,j+1};
            e[i][j+1][5]={i,j};
        }
    }

    for (int i=10;i<=13;i++){
        for (int j=1;j<11+(i-10);j++){
            e[i][j][4]={i,j+1};
            e[i][j+1][5]={i,j};
        }
    }

    for (int i=14;i<=16;i++){
        for (int j=1;j<4-(i-14);j++){
            e[i][j][4]={i,j+1};
            e[i][j+1][5]={i,j};
        }
    }



    int T=1;
    cin>>T;
    while (T--){
        paralysis();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3648kb

input:

5
1
1 1
2
1 1
2 1
2
9 4
9 6
10
1 1
2 1
2 2
3 1
3 2
3 3
4 1
4 2
4 3
4 4
10
1 1
2 1
2 2
5 7
3 2
3 3
4 1
4 2
4 3
4 4

output:

0
1
2
6
13

result:

ok 5 number(s): "0 1 2 6 13"

Test #2:

score: -100
Wrong Answer
time: 4ms
memory: 3652kb

input:

100
81
1 1
16 1
11 4
13 8
12 3
12 12
11 1
4 2
9 5
8 10
5 5
9 7
3 2
14 1
7 11
13 7
10 2
8 3
9 8
10 6
12 10
6 7
11 2
7 3
13 12
8 6
17 1
10 5
5 12
13 9
13 1
9 4
5 10
11 8
13 4
5 4
9 1
7 8
5 6
13 13
5 1
9 3
8 8
8 5
13 2
13 5
11 3
9 2
6 4
3 3
8 2
13 11
8 7
5 7
6 10
11 9
10 3
11 10
6 3
7 1
4 4
15 2
7 2
3 ...

output:

205
387
212
510
385
228
157
42
332
93
1
141
107
66
25
140
399
309
14
225
92
196
267
20
106
237
312
454
173
89
225
300
29
7
109
182
434
294
59
165
282
52
14
166
86
183
35
148
341
131
201
300
0
110
115
55
26
9
63
162
170
29
465
172
213
8
55
0
255
113
104
419
4
350
79
113
75
373
66
29
486
364
7
194
95
...

result:

wrong answer 1st numbers differ - expected: '190', found: '205'