QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#152978#6305. Chinese Checkerchen_zexingWA 7ms3628kbC++172.7kb2023-08-29 03:54:412023-08-29 03:54:42

Judging History

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

  • [2023-08-29 03:54:42]
  • 评测
  • 测评结果:WA
  • 用时:7ms
  • 内存:3628kb
  • [2023-08-29 03:54:41]
  • 提交

answer

#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
int cnt[20]={0,1,2,3,4,13,12,11,10,9,10,11,12,13,4,3,2,1};
int st[20]={0,11,11,11,11,7,8,9,10,11,11,11,11,11,16,17,18,19};
int id1[20][15],id2[30][30],vis[125],x[125],y[125],f[30][30];
int px[125],py[125];
int dy[6]={0,-1,-1,0,1,1},dx[6]={1,1,0,-1,-1,0};
int main() {
    memset(id1,-1,sizeof(id1)),memset(id2,-1,sizeof(id2));
    for(int i=1,now=0;i<=17;i++){
        for(int j=1;j<=cnt[i];j++){
            now++;
            id1[i][j]=now;
            id2[j+st[i]-1][24-i+1]=now;
            x[now]=j+st[i]-1,y[now]=24-i+1;
        }
    }
    int T = 1, kase = 0;
    cin >> T;
    while (T--) {
        memset(f,0,sizeof(f));
        int n,ans=0;
        scanf("%d",&n);
        for(int i=1;i<=n;i++){
            scanf("%d%d",&px[i],&py[i]),f[x[id1[px[i]][py[i]]]][y[id1[px[i]][py[i]]]]=1;
            //cout<<x[id1[px[i]][py[i]]]<<" "<<y[id1[px[i]][py[i]]]<<endl;
        }
        for(int i=1;i<=n;i++){
            memset(vis,-1,sizeof(vis));
            queue <pair<int,int>> q;
            vis[id1[px[i]][py[i]]]=1;
            int stx=x[id1[px[i]][py[i]]],sty=y[id1[px[i]][py[i]]];
            assert(id2[stx][sty]==id1[px[i]][py[i]]);
            q.push({x[id1[px[i]][py[i]]],y[id1[px[i]][py[i]]]});
            while(!q.empty()){
                auto temp=q.front();
                q.pop();
                for(int j=0;j<6;j++){
                    int tx=-1,ty=-1;
                    for(int xx=temp.first+dx[j],yy=temp.second+dy[j];id2[xx][yy]!=-1;xx+=dx[j],yy+=dy[j]){
                        if(f[xx][yy]&&(xx!=stx||yy!=sty)){
                            tx=xx,ty=yy;
                            break;
                        }
                    }
                    if(tx!=-1){
                        int ox=tx*2-temp.first,oy=ty*2-temp.second;
                        if(ox<=0||oy<=0||ox>29||oy>29||id2[ox][oy]==-1) continue;
                        int fl=1;
                        for(int xx=tx+dx[j],yy=ty+dy[j];;xx+=dx[j],yy+=dy[j]){
                            assert(id2[xx][yy]!=-1);
                            if(f[xx][yy]&&(xx!=stx||yy!=sty)) fl=0;
                            if(xx==ox) break;
                        }
                        if(fl&&vis[id2[ox][oy]]==-1){
                            //cout<<i<<" "<<temp.first<<" "<<temp.second<<" "<<tx<<" "<<ty<<" "<<ox<<" "<<oy<<" "<<f[ox][oy]<<endl;
                            vis[id2[ox][oy]]=1,ans++,q.push({ox,oy});
                        }
                    }
                }
            }
            //cout<<i<<" "<<ans<<endl;
        }
        cout<<ans<<endl;
    }
    return 0;
}



Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3628kb

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

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:

224
493
271
568
438
319
177
39
381
89
1
159
110
75
26
147
471
424
10
246
92
200
338
16
112
392
421
515
233
84
271
349
25
7
124
256
569
329
53
175
391
50
10
224
82
249
30
161
374
149
281
410
0
109
127
71
22
5
62
245
207
26
562
219
314
4
52
0
378
119
107
494
0
428
79
105
76
451
80
31
599
472
6
208
95
...

result:

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