QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#745034#6305. Chinese Checkerlouhao088WA 9ms3948kbC++981.9kb2024-11-14 01:42:442024-11-14 01:42:44

Judging History

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

  • [2024-11-14 01:42:44]
  • 评测
  • 测评结果:WA
  • 用时:9ms
  • 内存:3948kb
  • [2024-11-14 01:42:44]
  • 提交

answer

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

const int MAXT=100,MAXN=121;

int T,n,X[MAXN+5],Y[MAXN+5];
int L[20],R[20],ans;//17*17
int row[20][20],col[20][20],lea[20][20];

inline int Trans(int x,int y)
{
	if(y<=4 || (10<=y && y<=13)) return x+4;
	return x+y-5;
}
inline int Count(int y)
{
	if(y<=4 || (10<=y && y<=13)) return y;
	return 18-y;
}

inline int rsum(int y,int L,int R)
{
	if(L==R) return 0;
	if(L>R) swap(L,R);
	return row[y][R-1]-row[y][L];
}
inline int csum(int x,int L,int R)
{
	if(L==R) return 0;
	if(L>R) swap(L,R);
	return col[x][R-1]-col[x][L];
}
inline int lsum(int b,int L,int R)
{
	if(L==R) return 0;
	if(L>R) swap(L,R);
	return lea[b][R-1]-lea[b][L];
}

bool V[20][20];
int DFS(int x,int y)
{
	int res=0;
	for(int i=1,rx,ry;i<=n;i++)
		if(X[i]==x || Y[i]==y || Y[i]-X[i]==y-x)
		{
			ry=2*Y[i]-y;
			if(ry<1 || 17<ry) continue;
			rx=2*X[i]-x;
			if(rx<L[ry] || R[ry]<rx) continue;
			if(rx==x && csum(x,y,ry)>1) continue;
			if(ry==y && rsum(y,x,rx)>1) continue;
			if(ry-rx==y-x && lsum(y-x+9,x,rx)>1) continue;
			if(V[ry][rx]) continue;
			V[ry][rx]=1,res+=DFS(rx,ry)+1;
		}
	return res;
}

int main()
{
	for(int i=1;i<=17;i++) L[i]=Trans(1,i),R[i]=Trans(Count(i),i);
	scanf("%d",&T);
	while(T--)
	{
		scanf("%d",&n);
		for(int i=1;i<=17;i++)
			for(int j=1;j<=17;j++)
				row[i][j]=col[i][j]=lea[i][j]=0;
		for(int i=1;i<=n;i++)
		{
			scanf("%d %d",&Y[i],&X[i]);
			X[i]=Trans(X[i],Y[i]);
			++row[Y[i]][X[i]],++col[X[i]][Y[i]],++lea[Y[i]-X[i]+9][X[i]];
		}
		for(int i=1;i<=17;i++)
			for(int j=1;j<=17;j++)
				row[i][j]+=row[i][j-1],col[i][j]+=col[i][j-1],lea[i][j]+=lea[i][j-1];
		ans=0;
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=17;j++)
				for(int k=1;k<=17;k++)
					V[j][k]=0;
			for(int j=1;j<=n;j++) V[Y[j]][X[j]]=1;
			Y[i]-=17;
			ans+=DFS(X[i],Y[i]+17);
			Y[i]+=17;
		}
		printf("%d\n",ans);
	}
	return 0;
}

詳細信息

Test #1:

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

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

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:

190
368
210
491
370
224
151
39
328
87
1
131
103
65
25
137
391
294
10
214
82
188
261
16
102
236
300
439
172
84
211
281
25
7
104
181
429
282
51
163
265
47
10
149
79
181
30
145
328
122
199
289
0
105
114
53
22
5
59
159
167
26
446
163
209
4
52
0
251
109
100
401
0
347
75
105
73
353
65
28
472
352
6
190
90
...

result:

wrong answer 2nd numbers differ - expected: '376', found: '368'