QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#243939#6305. Chinese CheckerwbjjjjjWA 4ms3692kbC++142.0kb2023-11-08 19:28:582023-11-08 19:28:58

Judging History

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

  • [2023-11-08 19:28:58]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:3692kb
  • [2023-11-08 19:28:58]
  • 提交

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}};

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;
}

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[i][0];
        int nxty=now.second+dir[i][1];
        int dis=1;
        while(vis[nxtx][nxty]==0 && a[nxtx][nxty]==0)
        {
            nxtx+=dir[i][0]; nxty+=dir[i][1];
            dis++;
        }
        if(nxtx==ori.first && nxty==ori.second) continue;
        if(a[nxtx][nxty]==1)
        {
            int lastx=nxtx+dis*dir[i][0];
            int lasty=nxty+dis*dir[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;
                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;
}

詳細信息

Test #1:

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

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

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:

371
524
264
681
548
242
227
42
501
100
1
184
95
78
18
172
454
381
10
206
96
193
368
16
103
510
316
547
155
93
239
386
24
8
156
207
451
360
42
271
315
51
10
118
77
273
31
176
489
126
249
367
0
134
72
34
19
5
64
220
203
27
492
239
346
4
50
0
376
112
110
413
0
454
85
99
57
351
67
24
588
513
4
286
118
0...

result:

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