QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#474646 | #8835. Goodman | ucup-team866 | WA | 1ms | 7980kb | C++14 | 395b | 2024-07-12 21:36:00 | 2024-07-12 21:36:01 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 6;
int T, n, p[N], q[N], v[N];
int main() {
cin >> T;
while (T --) {
scanf ("%d", &n);
for (int i=1; i<=n; i++)
scanf ("%d", &p[i]), v[i] = 0;
for (int i=1, _=0; i<=n; i++)
for (int j=p[i]; !v[j]; j=p[j])
q[j] = ++ _, v[j] = 1;
for (int i=1; i<=n; i++)
printf ("%d ", q[i]); puts ("");
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 7968kb
input:
2 4 1 2 3 4 6 6 5 4 3 2 1
output:
1 2 3 4 2 4 6 5 3 1
result:
ok Correct (2 test cases)
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 7980kb
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 5 4 6 2 3 5 4 2 6 1 3 1 3 4 2 2 1 4 6 5 3 3 6 2 1 4 5 3 4 2 6 5 1 1 3 5 4 2 1 2 5 4 6 3 2 1 3 4 1 6 4 5 3 2 5 4 6 2 3 1 2 1 5 3 4 6 2 5 1 3 4 6 3 2 6 1 4 5 4 5 3 6 1 2 3 2 6 1 5 4 4 3 5 6 1 2 4 5 2 6 3 1 5 6 2 4 3 1 4 5 6 2 1 3 4 3 2 6 5 1 6 1 2 3 5 4 2 5 4 6 1 3 2 3 6 1 5 4...
result:
wrong answer Jury found better answer than participant (test case 1)