QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#107854 | #6503. DFS Order 3 | changtu | WA | 0ms | 3752kb | C++23 | 1.0kb | 2023-05-22 22:47:22 | 2023-05-22 22:47:22 |
Judging History
answer
#include<iostream>
#include<algorithm>
#include<string.h>
#include<vector>
using namespace std;
// #define debug(x) cout<<"[debug]"#x<<"="<<x<<endl
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
const ld eps=1e-8;
const int INF=0x3f3f3f3f,mod=998244353;
#define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define debug(...)
#include<debug>
#else
#define debug(...)
#endif
const int N=1003;
int a[N][N];
int id[N];
bool vis[N];
vector<pii> path;
void solve()
{
path.clear();
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++) vis[i]=false;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++) scanf("%d",&a[i][j]);
id[a[i][1]]=i;
}
for(int i=n;i>=1;i--)
{
int j=id[a[1][i]];
vis[a[j][1]]=true;
if(n>=2&&!vis[a[j][2]]) path.push_back({a[j][1],a[j][2]});
}
for(auto [x,y]:path) printf("%d %d\n",x,y);
puts("");
}
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
solve();
}
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3752kb
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 2 1 4 2 3 2 2 1 5 3 4 2
result:
wrong output format Unexpected end of file - int32 expected (test case 4)