QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#474663#8835. Goodmanucup-team866WA 1ms8048kbC++14392b2024-07-12 21:49:402024-07-12 21:49:40

Judging History

This is the latest submission verdict.

  • [2024-07-12 21:49:40]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 8048kb
  • [2024-07-12 21:49:40]
  • Submitted

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=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: 1ms
memory: 7892kb

input:

2
4
1 2 3 4
6
6 5 4 3 2 1

output:

1 2 3 4 
1 3 5 6 4 2 

result:

ok Correct (2 test cases)

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 8048kb

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

result:

wrong answer Jury found better answer than participant (test case 8)