QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#244003#6305. Chinese CheckerwbjjjjjWA 5ms3684kbC++142.5kb2023-11-08 20:15:022023-11-08 20:15:04

Judging History

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

  • [2023-11-08 20:15:04]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:3684kb
  • [2023-11-08 20:15:02]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

int t,n;
int space[25]={0,4,4,4,4,0,1,2,3,4,3,2,1,0,4,4,4,4};
int num[25]={0,1,2,3,4,13,12,11,10,9,10,11,12,13,4,3,2,1};
int a[20][20];
bool vis[20][20];
typedef pair<int,int>node;
vector<node>w;
int tot;

int dir[10][5]={{0,1},{1,0},{1,1},{-1,-1},{-1,0},{0,-1}};
int dir2[10][5]={{0,1},{1,-1},{1,0},{-1,0},{-1,1},{0,-1}};

void setbod() // 边界
{
    for(int i=1;i<=17;++i) 
        for(int j=0;j<=space[i];++j)
            a[i][j]=-1;
    for(int i=1;i<=17;++i)
        for(int j=space[i]+num[i]+1;j<=13;++j)
            a[i][j]=-1;
    for(int i=1;i<=17;++i) a[i][0]=a[i][14]=-1;
    for(int i=0;i<=14;++i) a[0][i]=a[18][i]=-1;
}

int _dir(int line,int now_dir,int row)
{
    if(line>=9) return dir2[now_dir][row];
    return dir[now_dir][row];
}

void dfs(node now,int last_dir,node ori)
{
    for(int i=0;i<6;++i)
    {
        if(i==last_dir) continue;
        int nxtx=now.first+_dir(now.first,i,0);
        int nxty=now.second+_dir(now.first,i,1);
        int dis=1;
        while(vis[nxtx][nxty]==0 && a[nxtx][nxty]==0)
        {
            nxtx+=_dir(nxtx,i,0); nxty+=_dir(nxtx,i,1);
            dis++;
        }
        if(nxtx==ori.first && nxty==ori.second) continue;
        if(a[nxtx][nxty]==1)
        {
            int lastx=nxtx; int lasty=nxty;
            for(int j=1;j<=dis;++j)
            {
                lastx+=_dir(lastx,i,0);
                lasty+=_dir(lasty,i,1);
            }
            if(lastx>17||lastx<1||lasty>13||lasty<1) continue;
            if(a[lastx][lasty]==0 && vis[lastx][lasty]==0)
            {
                vis[lastx][lasty]=1;
                // cout<<"test "<<now.first<<' '<<now.second-space[now.first]<<' '<<nxtx<<' '<<nxty-space[nxtx]<<' '<<lastx<<' '<<lasty-space[lastx]<<endl;
                tot++;
                dfs(node(lastx,lasty),5-i,ori);
            }
        }
    }
}

int main()
{
    cin>>t;
    while(t--)
    {
        cin>>n; memset(a,0,sizeof(a));
        tot=0;
        while(!w.empty()) w.pop_back();
        setbod();
        for(int i=1;i<=n;++i) 
        {
            int l,r;
            cin>>l>>r;
            a[l][r+space[l]] = 1;
            w.push_back(node(l,r+space[l]));
        }
        for(int i=0;i<n;++i)
        {
            dfs(w[i],6,w[i]);
            memset(vis,0,sizeof(vis));
        }
        cout << tot << endl;
    }
    // system("pause");
    return 0;
}
/*
1
8
13 9
13 1
9 4
5 10
11 8
13 4
5 4
9 1

*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 5ms
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:

456
891
295
1142
730
275
231
45
520
92
1
267
122
94
19
184
715
505
9
311
141
188
626
12
136
383
706
792
301
116
329
439
26
14
233
191
674
539
50
208
369
58
10
187
65
262
29
225
660
176
333
599
0
121
104
47
21
5
115
289
170
24
651
198
316
4
63
0
451
145
143
853
0
633
92
95
91
596
64
49
977
846
8
326
...

result:

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