QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#751890#6305. Chinese CheckerchenyitaooooWA 7ms3900kbC++231.8kb2024-11-15 21:12:182024-11-15 21:12:19

Judging History

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

  • [2024-11-15 21:12:19]
  • 评测
  • 测评结果:WA
  • 用时:7ms
  • 内存:3900kb
  • [2024-11-15 21:12:18]
  • 提交

answer

// start at 20:44
#include<bits/stdc++.h>
#define Ri register int 
using namespace std;
int vis[22][22],vis2[22][22],n,ans;
void clr(int a[22][22]){
	for(Ri i=1; i<=20; ++i){
		for(Ri j=1; j<=20; ++j) a[i][j]=0;
	}
}
void get(int &x,int &y){
	int xx=x;
	if(xx>9) xx=18-xx;
	if(xx<=4) y+=4;
	else y+=(xx-5);
}
int ck(int x,int y){
	if(x<1 || x>=20 || y<1 || y>=20) return 0;
	if(x>9) x=18-9;
	if(x<=4){
		return (y>4)&(y<=4+x);
	}
	else{
		return (y>x-5)&(y<=13);
	}
}
void dfs(int x,int y){
	for(int i=1; i<=20; ++i){
		if(abs(y-i)%2==0 && vis[x][(i+y)/2]==1 && ck(x,i)==1 && vis2[x][i]==0 && vis[x][i]==0){
			int tot=0;
			for(Ri j=1; j<abs(i-y); ++j){
				tot+=vis[x][min(y,i)+j];
			}
			if(tot==1){
				ans++;
				vis2[x][i]=1;
				dfs(x,i);
			}
		}
	}
	for(int i=1; i<=20; ++i){
		if(abs(i-x)%2==0 && vis[(i+x)/2][y]==1 && ck(i,y)==1 && vis2[i][y]==0 && vis[i][y]==0){
			int tot=0;
			for(Ri j=1; j<abs(x-i); ++j){
				tot+=vis[min(x,i)+j][y];
			}
			if(tot==1){
				ans++;
				vis2[i][y]=1;
				dfs(i,y);
			}
		}
	}
	for(int i=-20; i<=20; i+=2){
		if(ck(x+i,y+i)==1 && vis[(x+i+x)/2][(y+i+y)/2]==1 && vis2[x+i][y+i]==0 && vis[x+i][y+i]==0){
			int tot=0;
			for(Ri j=1; j<abs(i); ++j){
				tot+=vis[min(x,x+i)+j][min(y,y+i)+j];
			}
			if(tot==1){
				ans++;
				vis2[x+i][y+i]=1;
				dfs(x+i,y+i);
			}
		}
	}
}
void Sol(){
	clr(vis);
	scanf("%d",&n);
	for(Ri i=1; i<=n; ++i){
		int x,y;
		scanf("%d %d",&x,&y);
//		printf("%d\n",ck(x,y));
		get(x,y);
		vis[x][y]=1;
	}
	ans=0;
	for(Ri i=1; i<=20; ++i){
		for(Ri j=1; j<=20; ++j){
			if(vis[i][j]==0) continue;
			clr(vis2);
			vis2[i][j]=1,vis[i][j]=0;
			dfs(i,j);
			vis[i][j]=1;
		}
	}
	printf("%d\n",ans);
}
int main(){
	int T;
	scanf("%d",&T);
	while(T--) Sol();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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:

258
449
220
654
355
265
223
70
385
110
1
126
114
77
19
159
317
269
33
236
78
184
237
39
114
309
332
384
117
105
368
287
46
8
130
162
279
292
76
171
294
90
33
80
100
217
53
149
447
123
163
234
0
124
82
32
45
28
79
211
188
52
410
195
326
27
60
0
292
105
118
426
23
405
100
127
68
422
80
21
522
453
6
27...

result:

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