QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#115217 | #5956. Paradox Sort | Pittow | 0 | 164ms | 1748kb | C++14 | 970b | 2023-06-25 09:15:30 | 2023-06-25 09:15:31 |
Judging History
answer
#include<cstdio>
int T,n,k,i,j,a[104][104];
bool b[104],v[104];//confirmed,visited
void dfs(int g){
v[g]=0;
for(int i=0;i<n;++i)if(v[i]&&a[g][i])dfs(i);
}bool check(int cu,int de){
if(cu==n||a[de][cu])cu=de;
b[de]=0;
for(int i=0;i<n;++i)v[i]=b[i];
if(b[k])dfs(k);
b[de]=1;
if(cu<n)for(int i=0;i<n;++i)if(a[cu][i])v[i]=0;
for(int i=0;i<n;++i)if(b[i]&&v[i])return 0;
return 1;
}int main(){
scanf("%d",&T);
for(int t=0;t<T;++t){
scanf("%d%d",&n,&k);if(t==80)printf("%d %d\n",n,k);
for(i=0;i<n;++i)
for(j=0;j<n;++j)if(i!=j){
char c;
while(c=getchar(),c!='Y'&&c!='N');
a[i][j]=c=='Y';if(t==80)putchar(c);
}getchar();
// printf("Case #%d:",t+1);
for(i=0;i<n;++i)b[i]=1;
int cur=n;
if(!check(n,n)){0&&printf(" IMPOSSIBLE");goto end;}
for(i=0;i<n;++i){
for(j=0;j<n;++j)
if(b[j]&&check(cur,j))goto aha;
aha:b[j]=0;//printf(" %d",j);
if(i==0||a[j][cur])cur=j;
}end:0&&puts("");
}return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 1748kb
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:
1 0
result:
wrong answer 1st lines differ - expected: 'Case #1: 1 2 0', found: '1 0'
Subtask #2:
score: 0
Wrong Answer
Test #2:
score: 0
Wrong Answer
time: 164ms
memory: 1748kb
input:
100 39 0 -YNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN N-YNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN YN-YNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN YYN-YNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN YYYN-YNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN YYYYN-YNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN YYYYYN-YNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN YYYYYYN-YNN...
output:
2 0 NY
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: '2 0'