QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#132617#6503. DFS Order 3Scapegoat_DawnWA 1ms3624kbC++14987b2023-07-30 19:44:522023-07-30 19:45:23

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-30 19:45:23]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3624kb
  • [2023-07-30 19:44:52]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
inline int read() {
    int x = 0;
    char c = getchar();
    bool f = 0;
    while(!isdigit(c)) f |= (c == '-'), c = getchar();
    while(isdigit(c)) x = (x * 10) + (c ^ 48), c = getchar();
    return f ? -x : x;
}
const int maxn = 1005;
int T, n;
int D[maxn][maxn], Vst[maxn];
int main() {
//    freopen("G.in", "r", stdin);
//    freopen("G.out", "w", stdout);
    T = read();
    while(T--) {
        n = read();
        for(register int i = 1; i <= n; ++i) Vst[i] = 0;
        for(register int i = 1; i <= n; ++i)
            for(register int j = 1; j <= n; ++j) D[i][j] = read();
        for(register int i = n; i > 1; --i) {
            int x = D[1][i];
            Vst[x] = 1;
            for(register int j = 2; j <= n; ++j)
                if(!Vst[D[x][j]]) {
                    printf("%d %d\n", x, D[x][j]);
                    Vst[D[x][j]] = 1;
                }
        }
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4
2
1 2
2 1
3
1 2 3
2 1 3
3 2 1
4
1 2 3 4
2 1 3 4
3 2 4 1
4 2 1 3
5
1 2 4 3 5
2 4 1 3 5
3 5 1 2 4
4 2 1 3 5
5 3 1 2 4

output:

2 1
3 2
3 1
4 2
4 1
4 3
5 3
5 1
5 2
5 4

result:

wrong answer ord[1] didn't pass the test (test case 2)