QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#115665#6503. DFS Order 3szsz#WA 1ms3484kbC++201.1kb2023-06-26 15:16:152023-06-26 15:16:18

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-26 15:16:18]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3484kb
  • [2023-06-26 15:16:15]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=2006;
#define rep( i , a , b ) for( int i = (a) , i##end = (b) ; i <= i##end ; ++ i )
#define per( i , a , b ) for( int i = (a) , i##end = (b) ; i >= i##end ; -- i )
#define pii pair<int,int>
#define fi first
#define se second
void solve();
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    int T=1;
    cin>>T;
    while(T--)solve();
}
int n;
int D[MAXN][MAXN];
int bac[MAXN][MAXN] , tp[MAXN];
void solve(){
    scanf("%d",&n);
    rep( i , 1 , n ) {
        rep( j , 1 , n ) scanf("%d",D[i] + j);
        rep( j , 1 , n ) bac[i][D[i][j]] = j;
    }
    int top = n;
    vector<pii> res;
    rep( i , 1 , n - 1 ) {
        int v = D[1][top];
        int ct = 2;
        while( D[v][ct] == -1 ) ++ ct;
        int u = D[v][ct];
        res.emplace_back( u , v );
        rep( j , 1 , n ) D[j][bac[j][v]] = -1;
        while( D[1][top] == -1 ) -- top;
    }
    for( auto& [u , v] : res ) printf("%d %d\n",u,v);
//    puts("SSS");
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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:


result:

wrong output format Unexpected end of file - int32 expected (test case 1)