QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#129325#5509. Kooky Tic-Tac-ToeForever_Young#WA 17ms3832kbC++141.6kb2023-07-22 15:12:202023-07-22 15:12:21

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-22 15:12:21]
  • 评测
  • 测评结果:WA
  • 用时:17ms
  • 内存:3832kb
  • [2023-07-22 15:12:20]
  • 提交

answer

#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
using namespace std;
int t,n,k,tot,head[2],tail[2],ed;
char ch[6][6];
pair<int,int> p[2][40],ep,w[4];
int endg(){
	int tmp=0;
	for (int i=0;i<n;i++)
	for (int j=0;j<n;j++)
	if (ch[i][j]!='.'){
		tmp+=1;
		for (int h=0;h<4;h++){
			int f=1;
			for (int kk=1;kk<k;kk++)
			if (i+kk*w[h].fi<0||i+kk*w[h].fi>=n||j+kk*w[h].se>=n||ch[i+kk*w[h].fi][j+kk*w[h].se]!=ch[i][j]){
				f=0;
				break;
			}
			if (f) return 1;
		}
	}
	if (tmp==n*n) return 1;
	return 0;
}
int check(){
	tot=0;
	tail[0]=tail[1]=0;
	ed=2;
	for (int i=0;i<n;i++)
	for (int j=0;j<n;j++)
	if (ch[i][j]!='.'){
		tot++;
		int typ;
		if (ch[i][j]=='x') typ=0;
		else if (ch[i][j]=='o') typ=1;
		p[typ][tail[typ]++]=mp(i,j);
		if (endg()){
			char tmp;
			tmp=ch[i][j];
			ch[i][j]='.';
			if (!endg()){
				ed=typ;
				ep=mp(i,j);
			}
			ch[i][j]=tmp;
		}
	}
	if (ed==2) return 2;
	//printf("%d %d\n",ep.fi,ep.se);
	for (int i=0;i<tail[ed];i++)
	if (p[ed][i]==ep) swap(p[ed][i],p[ed][tail[ed]-1]);
	if (tail[ed]==tail[ed^1]) return ed^1;
	if (tail[ed]==tail[ed^1]+1) return ed;
	return 2;
}
int main(){
	//freopen("K.in","r",stdin);
	w[0]=mp(1,0);
	w[1]=mp(0,1);
	w[2]=mp(1,1);
	w[3]=mp(-1,1);
	scanf("%d",&t);
	while (t--){
		scanf("%d%d",&n,&k);
		for (int i=0;i<n;i++) scanf("%s",ch[i]);
		int f=check();
		if (f<2){
			printf("TAK\n");
			head[0]=head[1]=0;
			for (int i=0;i<tot;i++){
				printf("%d %d\n",p[f][head[f]].fi+1,p[f][head[f]].se+1);
				head[f]++;
				f^=1;
			}
		}
		else printf("NIE\n");
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

7
3 3
x.o
xxx
o.o
4 3
xx.x
...o
..o.
.o..
3 3
xoo
oxx
xoo
3 2
xoo
oxx
xoo
3 3
xox
.o.
xox
3 2
xo.
..x
xo.
3 3
x..
.x.
..x

output:

TAK
1 1
1 3
2 1
3 1
2 2
3 3
2 3
TAK
1 1
2 4
1 2
3 3
1 4
4 2
TAK
1 2
1 1
1 3
2 2
2 1
2 3
3 2
3 1
3 3
NIE
NIE
NIE
NIE

result:

ok correct (7 test cases)

Test #2:

score: -100
Wrong Answer
time: 17ms
memory: 3832kb

input:

10000
3 3
x.o
xxx
o.o
3 3
xoo
oxx
xoo
3 2
xoo
oxx
xoo
3 3
xox
.o.
xox
3 2
xo.
..x
xo.
3 2
oox
.xo
o.x
5 5
xxx..
xxo.x
xoo..
xxxox
.oooo
3 3
xxx
.o.
oo.
3 2
x.o
xo.
..o
3 2
..x
xxo
.o.
3 3
xxo
o..
oxo
3 2
oox
..x
...
3 3
xxo
...
.ox
3 3
.xo
...
oox
3 3
.x.
xo.
o.o
3 2
o..
xxo
.ox
3 2
x.x
xoo
x.o
3 2
...

output:

TAK
1 1
1 3
2 1
3 1
2 2
3 3
2 3
TAK
1 2
1 1
1 3
2 2
2 1
2 3
3 2
3 1
3 3
NIE
NIE
NIE
NIE
NIE
TAK
2 2
1 1
3 1
1 2
3 2
1 3
NIE
NIE
NIE
NIE
NIE
NIE
NIE
NIE
NIE
NIE
NIE
NIE
NIE
NIE
NIE
NIE
TAK
1 2
1 1
1 3
1 4
2 3
2 2
2 4
4 1
3 1
4 2
3 2
4 3
NIE
NIE
NIE
NIE
NIE
TAK
2 1
1 1
2 3
4 3
2 4
1 3
3 1
1 4
3 3
2 2
...

result:

wrong answer Jury claims solution exists, contestant claims it does not (test case 546)