QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#679369#6305. Chinese CheckerTggdbWA 4ms3864kbC++203.9kb2024-10-26 17:28:162024-10-26 17:28:16

Judging History

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

  • [2024-10-26 17:28:16]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:3864kb
  • [2024-10-26 17:28:16]
  • 提交

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[14][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: 3568kb

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: 3864kb

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:

194
358
189
499
360
226
161
45
310
96
1
124
108
60
25
142
374
309
17
227
92
186
262
23
107
232
298
437
173
90
218
302
32
7
113
183
414
298
60
161
284
53
17
133
88
185
38
148
336
133
194
282
0
111
115
54
29
12
60
157
174
31
445
178
216
11
55
0
258
115
104
400
7
350
79
112
64
369
66
29
473
349
7
201
1...

result:

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