QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#152973#6305. Chinese Checkerchen_zexingWA 8ms3636kbC++172.6kb2023-08-29 03:36:492023-08-29 03:36:50

Judging History

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

  • [2023-08-29 03:36:50]
  • 评测
  • 测评结果:WA
  • 用时:8ms
  • 内存:3636kb
  • [2023-08-29 03:36:49]
  • 提交

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<=19;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]){
                            if(f[xx][yy]) 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;
}



詳細信息

Test #1:

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

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

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
485
271
565
433
312
177
39
375
89
1
158
110
75
26
147
466
421
10
246
84
200
338
16
112
386
421
513
233
84
269
349
25
7
124
254
568
329
53
175
385
50
10
212
82
249
30
161
366
149
281
408
0
109
126
71
22
5
59
244
207
26
562
218
314
4
52
0
377
119
107
494
0
426
79
105
76
451
80
31
599
463
6
204
95
...

result:

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