QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#827359#4426. Divided MechanismKevin5307AC ✓2ms3816kbC++23953b2024-12-22 22:04:582024-12-22 22:04:58

Judging History

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

  • [2024-12-22 22:04:58]
  • 评测
  • 测评结果:AC
  • 用时:2ms
  • 内存:3816kb
  • [2024-12-22 22:04:58]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int N=110;
int t,n,m,tot,q,x[N],y[N],mp[N][N];
char s[N];
int chk (int x,int y) {
	if (x<=0||y<=0||x>n||y>m) {return 1;}
	return 1-mp[x][y];
}
int main () {
	scanf("%d",&t);
	for (int ii=1;ii<=t;ii++) {
		tot=0;
		scanf("%d%d%d",&n,&m,&q);
		for (int i=1;i<=n;i++) {
			scanf("%s",s+1);
			for (int j=1;j<=m;j++) {
				mp[i][j]=(s[j]=='A');
				if (s[j]=='B') {++tot;x[tot]=i,y[tot]=j;}
			}
		}
		scanf("%s",s+1);
		int flg=0;
		for (int i=1;i<=q;i++) {
			int dx=(s[i]=='N'?-1:(s[i]=='S'?1:0)),dy=(s[i]=='W'?-1:(s[i]=='E'?1:0));
			for (int j=1;;j++) {
				if (j>=20) {flg=1;break;}
				int flgg=1;
				for (int k=1;k<=tot;k++) {
					if (!chk(x[k]+dx,y[k]+dy)) {flgg=0;break;}
				}
				if (!flgg) {break;}
				for (int k=1;k<=tot;k++) {x[k]+=dx,y[k]+=dy;}
			}
			if (flg) {break;}
		}
		if (flg) {printf("TAK\n");}
		else {printf("NIE\n");}
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3816kb

input:

1000
10 9 4
AA...AAAA
A......AA
A..BBB..A
A...B...A
A...B...A
AA..BBAAA
A..BB...A
A......AA
A...AAAAA
AAAAAAAAA
WSEN
9 10 4
AAAAAAAAAA
A...A....A
A.........
A..B...B..
AA.BBBBB..
AA..B..B.A
AA..A....A
AAA.A...AA
AAAAAAAAAA
ESNE
9 10 7
AAAAAAAAAA
A...A....A
A.........
A..B...B..
AA.BBBBB..
AA..B..B.A...

output:

TAK
TAK
TAK
TAK
TAK
TAK
TAK
TAK
TAK
TAK
TAK
TAK
TAK
TAK
TAK
TAK
TAK
TAK
TAK
TAK
TAK
TAK
TAK
TAK
TAK
TAK
TAK
TAK
TAK
TAK
TAK
TAK
TAK
NIE
NIE
NIE
NIE
NIE
NIE
NIE
NIE
NIE
NIE
NIE
NIE
NIE
NIE
NIE
NIE
NIE
NIE
NIE
NIE
NIE
NIE
NIE
NIE
NIE
NIE
NIE
TAK
TAK
TAK
TAK
TAK
TAK
TAK
TAK
TAK
TAK
TAK
TAK
TAK
TAK
TAK
...

result:

ok 1000 lines

Extra Test:

score: 0
Extra Test Passed