QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#265439#6503. DFS Order 3AzusamitsusaWA 1ms3420kbC++14661b2023-11-25 18:26:202023-11-25 18:26:20

Judging History

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

  • [2023-11-25 18:26:20]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3420kb
  • [2023-11-25 18:26:20]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define PII pair<int,int>
#define all(x) (x).begin(),(x).end()
const int N = 5e5+10;
void solve(){
    int n;cin>>n;
    int a[n+1][n+1];
    vector<int>pos(n+1);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            cin>>a[i][j];
            pos[a[i][j]]=max(pos[a[i][j]],j);
        }
    }
    int mn=1e9,ans=1;
    for(int i=1;i<=n;i++)if(pos[i]<mn)ans=i,mn=pos[i];
    for(int i=1;i<=n;i++)if(i!=ans)cout<<i<<' '<<ans<<endl;
}
signed main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int t=1;cin>>t;
    while(t--)solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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
1 2
3 2
1 2
3 2
4 2
2 1
3 1
4 1
5 1

result:

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