QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#115665 | #6503. DFS Order 3 | szsz# | WA | 1ms | 3484kb | C++20 | 1.1kb | 2023-06-26 15:16:15 | 2023-06-26 15:16:18 |
Judging History
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)