Task: | Sums |
Sender: | team_a |
Submission time: | 2020-10-03 13:55:52 +0300 |
Language: | C++ (C++11) |
Status: | READY |
Result: | WRONG ANSWER |
test | verdict | time | |
---|---|---|---|
#1 | WRONG ANSWER | 0.01 s | details |
#2 | WRONG ANSWER | 0.01 s | details |
#3 | WRONG ANSWER | 0.01 s | details |
#4 | WRONG ANSWER | 0.01 s | details |
#5 | WRONG ANSWER | 0.01 s | details |
#6 | RUNTIME ERROR | 0.04 s | details |
#7 | RUNTIME ERROR | 0.04 s | details |
#8 | RUNTIME ERROR | 0.04 s | details |
#9 | RUNTIME ERROR | 0.04 s | details |
#10 | RUNTIME ERROR | 0.04 s | details |
Code
#include <iostream> using namespace std; int main() { int n; cin >> n; // Cycles int c = 0; std::ios::sync_with_stdio(true); int *p = new int[n]; // Parents int *v = new int[n]; // Visited int *w = new int[n]; // Visited for (int i = 0; i < n; i++) { cin >> p[i]; p[i] -= 1; v[i] = 0; w[i] = -1; } for(int i = 0; i < n; i++) { if (v[i]) continue; // SKIP VISITED v[i] = 1; // Mark as visited w[i] = i; int j = p[i]; while(v[j] == 0) { // If we go back to beginning, w[j] = i; v[j] = 1; j = p[j]; } if (w[j] == i) { //std::cout << "f" << i << " " << j << endl; c++; } } cout << c << endl; return 0; }
Test details
Test 1
Verdict: WRONG ANSWER
input |
---|
10 -10 3 -1 4 4 1 6 7 9 3 20 2 7 10 -5 2 5 9 2 ... |
correct output |
---|
-2 32 10 13 12 |
user output |
---|
3 |
Test 2
Verdict: WRONG ANSWER
input |
---|
10 -10 -4 -7 -2 5 -8 0 -5 -5 5 20 3 8 10 1 5 6 7 ... |
correct output |
---|
-5 12 7 -13 -33 ... |
user output |
---|
2 |
Test 3
Verdict: WRONG ANSWER
input |
---|
10 0 -2 7 4 1 4 -5 8 9 -10 20 2 2 8 -5 2 8 9 -2 ... |
correct output |
---|
-17 -10 -12 -5 21 |
user output |
---|
4 |
Test 4
Verdict: WRONG ANSWER
input |
---|
10 0 6 -6 -9 7 -9 2 6 -4 -8 20 1 8 10 9 2 2 6 -10 ... |
correct output |
---|
6 30 -30 -9 |
user output |
---|
1 |
Test 5
Verdict: WRONG ANSWER
input |
---|
10 -8 6 0 8 1 -8 3 6 10 -6 20 2 5 7 -3 3 2 4 ... |
correct output |
---|
14 18 7 29 -20 |
user output |
---|
1 |
Test 6
Verdict: RUNTIME ERROR
input |
---|
100000 273768 -746242 141310 -177646 ... |
correct output |
---|
6647300100 16584491568 2201217278 4428835910 -5370398949 ... |
user output |
---|
(empty) |
Test 7
Verdict: RUNTIME ERROR
input |
---|
100000 -371240 -967819 -659618 -83603... |
correct output |
---|
-8551444 -14584129201 -9051387 1006850011 -1119500762 ... |
user output |
---|
(empty) |
Test 8
Verdict: RUNTIME ERROR
input |
---|
100000 954118 382497 -92991 199841 98... |
correct output |
---|
-31591117 3979951718 1018552734 1672204000 230714784 ... |
user output |
---|
(empty) |
Test 9
Verdict: RUNTIME ERROR
input |
---|
100000 -374041 -712493 -568255 490384... |
correct output |
---|
9993656711 4138033702 8839287 3596183407 -643074001 ... |
user output |
---|
(empty) |
Test 10
Verdict: RUNTIME ERROR
input |
---|
100000 257414 -141188 -721927 -67385 ... |
correct output |
---|
-47022095 -13947364 19483822021 10788657040 -4163257456 ... |
user output |
---|
(empty) |