QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#457679 | #8835. Goodman | ucup-team4074# | RE | 25ms | 3728kb | C++20 | 672b | 2024-06-29 13:39:16 | 2024-06-29 13:39:16 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
void solve();
using pii = pair<int, int>;
using db = double;
signed main(){
fast
int t = 1;
cin >> t;
for(int i = 1; i <= t; i++){
solve();
}
}
const int N = 3e5 + 10, M = N * 2, P = 998244353;
int n;
int a[N];
bool st[N];
void solve(){
cin >> n;
for(int i = 1; i <= n; i++) st[i] = 0;
for(int i = 1; i <= n; i++){
cin >> a[i];
}
for(int i = 1; i <= n; i++){
if(!st[i]){
int x = i;
while(!st[x]){
cout << x << ' ';
st[x] = 1;
x = a[x];
}
}
}
cout << '\n';
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3596kb
input:
2 4 1 2 3 4 6 6 5 4 3 2 1
output:
1 2 3 4 1 6 2 5 3 4
result:
ok Correct (2 test cases)
Test #2:
score: 0
Accepted
time: 1ms
memory: 3600kb
input:
873 6 1 5 2 4 6 3 6 5 1 6 4 3 2 4 1 4 3 2 6 2 1 6 5 4 3 6 4 5 1 3 6 2 6 6 2 1 5 4 3 5 1 5 4 3 2 6 1 2 6 3 5 4 4 2 1 3 4 6 1 6 4 2 3 5 6 6 1 3 5 2 4 6 2 1 4 5 3 6 6 3 4 1 5 2 6 6 4 1 5 2 6 3 6 5 2 1 4 6 3 6 4 1 6 2 3 5 6 5 1 3 4 6 2 6 6 2 5 4 1 3 6 6 2 5 1 4 3 6 5 2 3 6 4 1 6 6 1 2 5 4 3 6 2 3 4 6 1 ...
output:
1 2 5 6 3 4 1 5 3 6 2 4 1 2 4 3 1 2 3 6 4 5 1 4 3 2 5 6 1 6 3 2 4 5 1 2 5 3 4 1 2 3 6 4 5 1 2 3 4 1 2 6 5 3 4 1 6 4 5 2 3 1 2 3 4 5 6 1 3 2 4 5 6 1 4 2 3 5 6 1 5 6 3 2 4 1 4 2 3 6 5 1 5 6 2 3 4 1 6 3 5 2 4 1 6 3 5 4 2 1 5 4 6 2 3 1 6 3 2 4 5 1 2 3 4 6 5 1 5 2 6 3 4 1 4 2 3 6 5...
result:
ok Correct (873 test cases)
Test #3:
score: 0
Accepted
time: 25ms
memory: 3728kb
input:
46233 7 2 1 7 5 3 4 6 7 5 6 2 4 3 7 1 4 3 4 1 2 7 4 5 1 6 3 2 7 8 4 2 6 5 1 3 8 7 8 3 4 8 6 7 5 2 1 7 6 2 4 3 7 1 5 8 8 1 3 2 7 4 6 5 8 6 5 4 2 1 3 7 8 8 8 3 5 6 2 7 1 4 8 7 3 6 1 8 5 2 4 8 2 3 4 5 8 6 1 7 8 5 8 2 4 7 3 1 6 8 3 4 8 2 7 5 6 1 8 2 8 3 5 7 4 6 1 8 8 4 5 7 6 1 2 3 8 5 2 6 3 4 7 8 1 8 2 ...
output:
1 2 3 7 6 4 5 1 5 3 2 6 7 4 1 3 2 4 1 4 6 2 5 3 7 1 4 5 2 3 6 7 8 1 3 8 2 4 6 5 7 1 6 2 3 4 5 7 1 8 5 7 6 4 2 3 1 6 3 4 2 5 7 8 1 8 4 6 7 2 3 5 1 7 2 3 6 5 8 4 1 2 3 4 5 8 7 6 1 5 7 2 8 6 3 4 1 3 8 2 4 5 7 6 1 2 8 3 4 5 7 6 1 8 3 5 6 2 4 7 1 5 4 3 6 7 8 2 1 2 4 7 3 5 6 8 1 5 6 3 2 ...
result:
ok Correct (46233 test cases)
Test #4:
score: -100
Runtime Error
input:
1 999995 992870 548521 579550 387108 249895 990007 476463 686591 907510 311379 340877 491996 478527 996443 681309 483046 760005 905577 711115 275827 697004 737465 904964 381424 774578 217570 554656 914370 935328 624905 590395 761191 265062 978389 670994 184745 662928 389422 952905 447853 325275 9796...