QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#440405#5956. Paradox Sortas_lyr0 85ms3956kbC++141.3kb2024-06-13 17:58:172024-06-13 17:58:18

Judging History

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

  • [2024-06-13 17:58:18]
  • 评测
  • 测评结果:0
  • 用时:85ms
  • 内存:3956kb
  • [2024-06-13 17:58:17]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int N=110;
int n,st;
bool o[N][N];
vector <int> e[N];
bool vis[N],ver[N];
void dfs(int x){
	vis[x]=1;
	for(int i=0;i<(int)e[x].size();i++){
		int y=e[x][i];
		if(vis[y]||ver[y])
			continue;
		dfs(y);
	}
}
inline bool check(int x){
	for(int i=1;i<=n;i++)
		vis[i]=0;
	if(ver[st]==0)
		dfs(st);
	for(int i=1;i<=n;i++)
		if(ver[i]==0&&vis[i]==0&&o[x][i]==0)
			return 0;
	return 1;
}
void solve(int id){
	printf("Case #%d: ",id);
	scanf("%d%d",&n,&st);
	st++;
	for(int i=1;i<=n;i++)
		e[i].clear();
	memset(o,0,sizeof(o));
	memset(ver,0,sizeof(ver));
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++){
			char op;
			cin>>op;
			if(op=='Y'){
				e[i].push_back(j);
				o[i][j]=1;
			}
		}
	for(int i=1;i<=n;i++)
		vis[i]=0;
	dfs(st);
	for(int i=1;i<=n;i++)
		if(vis[i]==0){
			puts("IMPOSSIBLE");
			return ;
		}
	int pre=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(ver[j])
				continue;
			if(ver[st]&&o[st][j]==0)
				continue;
			ver[j]=1;
			if(check(j)){
				printf("%d ",j-1);
				pre=o[pre][j]?pre:j;
				break;
			}
			else
				ver[j]=0;
		}
	}
	puts("");
}
int main(){
	int T;
	scanf("%d",&T);
	for(int i=1;i<=T;i++)
		solve(i);
	return 0;
} 

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3888kb

input:

100
3 0
-YN
N-Y
YN-
2 0
-Y
N-
5 0
-YNNN
N-YNN
YN-YN
YYN-Y
YYYN-
5 1
-NYYY
Y-NNN
NY-NY
NYY-N
NYNY-
6 5
-YYNNY
N-YYNY
NN-NYN
YNY-NY
YYNY-Y
NNYNN-
4 0
-YYY
N-YN
NN-N
NYY-
2 0
-Y
N-
5 1
-NYNY
Y-YYY
NN-YY
YNN-N
NNNY-
7 5
-YYYYYY
N-NNYYN
NY-YNNN
NYN-NYN
NNYY-NN
NNYNY-N
NYYYYY-
8 0
-YNNNNNN
N-YNNNNN
YN-YNN...

output:

Case #1: 1 2 0 
Case #2: 0 1 
Case #3: 3 4 1 2 0 
Case #4: 0 
Case #5: 0 1 3 2 4 5 
Case #6: 0 3 1 2 
Case #7: 0 1 
Case #8: 0 1 2 4 3 
Case #9: IMPOSSIBLE
Case #10: 6 7 4 5 2 3 0 1 
Case #11: 0 2 1 
Case #12: 0 1 
Case #13: 0 1 
Case #14: IMPOSSIBLE
Case #15: IMPOSSIBLE
Case #16: 7 8 5 6 3 4 1 0 2 ...

result:

wrong answer 3rd lines differ - expected: 'Case #3: 3 4 2 1 0', found: 'Case #3: 3 4 1 2 0 '

Subtask #2:

score: 0
Wrong Answer

Test #2:

score: 0
Wrong Answer
time: 85ms
memory: 3956kb

input:

100
39 0
-YNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
N-YNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
YN-YNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
YYN-YNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
YYYN-YNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
YYYYN-YNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
YYYYYN-YNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
YYYYYYN-YNN...

output:

Case #1: 37 38 35 36 33 34 31 32 29 30 27 28 25 26 23 24 21 22 19 20 17 18 15 16 13 14 11 12 9 10 7 8 5 6 3 4 1 2 0 
Case #2: 0 
Case #3: 0 1 2 3 4 5 6 8 9 10 11 12 15 
Case #4: 4 12 6 8 9 7 5 10 3 11 1 2 0 
Case #5: IMPOSSIBLE
Case #6: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 26 2...

result:

wrong answer 1st lines differ - expected: 'Case #1: 37 38 36 35 34 33 32 ...13 12 11 10 9 8 7 6 5 4 3 2 1 0', found: 'Case #1: 37 38 35 36 33 34 31 ...4 11 12 9 10 7 8 5 6 3 4 1 2 0 '