QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#423109#5956. Paradox SortKalenist0 82ms3972kbC++201.2kb2024-05-27 21:08:402024-05-27 21:08:41

Judging History

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

  • [2024-05-27 21:08:41]
  • 评测
  • 测评结果:0
  • 用时:82ms
  • 内存:3972kb
  • [2024-05-27 21:08:40]
  • 提交

answer

#include<bits/stdc++.h>
#define N 110
#define For(i,a,b) for(register int i=a;i<=b;i++)
using namespace std;
int n,e[N][N],a[N],en;
bool ban[N],vis[N],mark[N];
char s[N][N];
inline void dfs(int x)
{
    mark[x]=true;
    For(i,1,n) if(!mark[i] && e[x][i]) dfs(i);
    return;
}

inline bool check(int x,int y)
{
    x=e[x][y]?x:y;
    For(i,0,n) mark[i]=ban[i];
    mark[x]=true;
    if(mark[en] && x != en) return false;
    if(!mark[en]) 
    {
        dfs(en);
        For(i,1,n) if(!mark[i] && !e[x][i]) return false;
    }
    return true;
}

int main()
{
    int T;scanf("%d",&T);
    For(test,1,T)
    {
        scanf("%d%d",&n,&en),en++;
        memset(e,false,sizeof(e));
        For(i,1,n) scanf("%s",s[i]+1);
        For(i,1,n) For(j,i+1,n)
            if(s[i][j] == 'Y') e[i][j]=true;
            else e[j][i]=true;
        memset(ban,false,sizeof(ban));
        printf("Case #%d: ",test);
        if(!check(0,0)) {printf("IMPOSSIBLE\n");continue;}
        for(int lst=0,i=1;i<=n;i++)
            For(j,1,n) if(!ban[j] && check(lst,j))
            {
                ban[j]=true,printf("%d ",j-1);
                lst=j;break;
            }
        printf("\n");
    }
    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: 1ms
memory: 3836kb

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: 0 1 
Case #2: 0 1 
Case #3: 0 1 
Case #4: 0 1 
Case #5: 0 1 2 5 
Case #6: 0 1 
Case #7: 0 1 
Case #8: 0 1 2 
Case #9: IMPOSSIBLE
Case #10: 0 1 
Case #11: 0 1 
Case #12: 0 1 
Case #13: 0 1 
Case #14: IMPOSSIBLE
Case #15: IMPOSSIBLE
Case #16: 0 2 
Case #17: 1 0 
Case #18: 0 1 2 3 6 4 5 
Case ...

result:

wrong answer 1st lines differ - expected: 'Case #1: 1 2 0', found: 'Case #1: 0 1 '

Subtask #2:

score: 0
Wrong Answer

Test #2:

score: 0
Wrong Answer
time: 82ms
memory: 3972kb

input:

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

output:

Case #1: 0 1 
Case #2: 0 1 
Case #3: 0 1 2 3 4 5 6 7 
Case #4: 0 1 
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 23 
Case #7: 0 1 2 
Case #8: 0 1 2 
Case #9: IMPOSSIBLE
Case #10: IMPOSSIBLE
Case #11: 19 1 
Case #12: 0 1 2 3 4 5 6 7 8 
Case #13: 0 1 
Case #1...

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: 0 1 '