Task: | Ice cream |
Sender: | Team Olari |
Submission time: | 2016-09-20 17:06:39 +0300 |
Language: | C++ |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.06 s | details |
#2 | ACCEPTED | 0.06 s | details |
#3 | ACCEPTED | 0.07 s | details |
#4 | ACCEPTED | 0.07 s | details |
#5 | ACCEPTED | 0.06 s | details |
#6 | ACCEPTED | 0.05 s | details |
#7 | ACCEPTED | 0.06 s | details |
#8 | ACCEPTED | 0.07 s | details |
#9 | ACCEPTED | 0.08 s | details |
#10 | ACCEPTED | 0.06 s | details |
#11 | ACCEPTED | 0.06 s | details |
#12 | ACCEPTED | 0.06 s | details |
#13 | ACCEPTED | 0.08 s | details |
#14 | ACCEPTED | 0.10 s | details |
#15 | ACCEPTED | 0.06 s | details |
#16 | ACCEPTED | 0.06 s | details |
#17 | ACCEPTED | 0.08 s | details |
#18 | ACCEPTED | 0.09 s | details |
#19 | ACCEPTED | 0.10 s | details |
#20 | ACCEPTED | 0.08 s | details |
Compiler report
input/code.cpp: In function 'void h(int)': input/code.cpp:12:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int i=0; i<v[s].size(); ++i){ ^ input/code.cpp: In function 'void hh(int)': input/code.cpp:21:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int i=0; i<v[s].size(); ++i){ ^
Code
#include <iostream> #include <vector> using namespace std; vector<int> v[101010]; int maut[101010], V, z[101010], t[101010], f[101010]; void h(int s) { if(z[s]) return; z[s] = 1; int a=f[s]; if(maut[a]==0) ++V; maut[a]=1; for(int i=0; i<v[s].size(); ++i){ h(v[s][i]); } } void hh(int s){ if(z[s]==2) return; z[s]=2; t[s]=V; maut[f[s]]=0; for(int i=0; i<v[s].size(); ++i){ hh(v[s][i]); } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, m; cin >> n >> m; for (int i = 0; i < n; ++i) { cin >> f[i]; } for (int i = 0; i < m; ++i) { int a, b; cin >> a >> b; v[--a].push_back(--b); v[b].push_back(a); } for(int i=0; i<n; ++i){ h(i); hh(i); V=0; } for(int i=0; i<n; ++i) cout << t[i] << " "; }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
47623 1000 6085 3581 2784 1594 9991 7789 ... |
correct output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
user output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
Test 2
Verdict: ACCEPTED
input |
---|
29933 10000 37075 97477 24892 91827 86196 ... |
correct output |
---|
2 6 1 1 5 1 1 7 9 2 2 2 1 1 3 ... |
user output |
---|
2 6 1 1 5 1 1 7 9 2 2 2 1 1 3 ... |
Test 3
Verdict: ACCEPTED
input |
---|
82771 50000 84 19 10 43 44 51 77 9 4 1 21 ... |
correct output |
---|
2 1 1 1 100 1 1 1 100 100 1 1 ... |
user output |
---|
2 1 1 1 100 1 1 1 100 100 1 1 ... |
Test 4
Verdict: ACCEPTED
input |
---|
11645 100000 3041 8953 9167 1268 2312 5911 ... |
correct output |
---|
6836 6836 6836 6836 6836 6836 ... |
user output |
---|
6836 6836 6836 6836 6836 6836 ... |
Test 5
Verdict: ACCEPTED
input |
---|
1041 100 43553 8035 14355 19335 24786 7... |
correct output |
---|
2 1 1 3 1 1 1 2 1 1 1 1 3 1 1 ... |
user output |
---|
2 1 1 3 1 1 1 2 1 1 1 1 3 1 1 ... |
Test 6
Verdict: ACCEPTED
input |
---|
55898 1000 73 44 15 26 63 51 15 71 73 48 ... |
correct output |
---|
1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 ... |
user output |
---|
1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 ... |
Test 7
Verdict: ACCEPTED
input |
---|
12027 10000 2456 845 5196 3813 3093 2331 2... |
correct output |
---|
2 5542 5542 1 5542 5542 5542 5... |
user output |
---|
2 5542 5542 1 5542 5542 5542 5... |
Test 8
Verdict: ACCEPTED
input |
---|
55977 50000 79310 84043 72794 74090 312 15... |
correct output |
---|
1 33498 33498 33498 33498 1 1 ... |
user output |
---|
1 33498 33498 33498 33498 1 1 ... |
Test 9
Verdict: ACCEPTED
input |
---|
16237 100000 57 43 3 66 59 10 24 41 56 23 5... |
correct output |
---|
100 100 100 100 100 100 100 10... |
user output |
---|
100 100 100 100 100 100 100 10... |
Test 10
Verdict: ACCEPTED
input |
---|
93552 100 31 7952 1106 2779 1980 8776 56... |
correct output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
user output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
Test 11
Verdict: ACCEPTED
input |
---|
100000 1000 99793 93845 56091 42020 27225 ... |
correct output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
user output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
Test 12
Verdict: ACCEPTED
input |
---|
100000 10000 45 12 5 45 21 73 12 34 97 14 6... |
correct output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
user output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
Test 13
Verdict: ACCEPTED
input |
---|
100000 50000 3967 8608 4873 6065 3304 1388 ... |
correct output |
---|
27 10 2 1 205 2 1 5 752 9 2 26... |
user output |
---|
27 10 2 1 205 2 1 5 752 9 2 26... |
Test 14
Verdict: ACCEPTED
input |
---|
70000 100000 9570 57890 88434 83611 76325 3... |
correct output |
---|
1 1 1 47966 47966 47966 47966 ... |
user output |
---|
1 1 1 47966 47966 47966 47966 ... |
Test 15
Verdict: ACCEPTED
input |
---|
100000 100 84 34 32 36 64 83 29 4 36 57 9... |
correct output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
user output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
Test 16
Verdict: ACCEPTED
input |
---|
100000 1000 7080 7863 895 4001 3806 8637 7... |
correct output |
---|
1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 ... |
user output |
---|
1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 ... |
Test 17
Verdict: ACCEPTED
input |
---|
100000 10000 13821 30085 25414 18462 40885 ... |
correct output |
---|
1 1 3 1 1 2 1 1 1 2 1 1 1 1 1 ... |
user output |
---|
1 1 3 1 1 2 1 1 1 2 1 1 1 1 1 ... |
Test 18
Verdict: ACCEPTED
input |
---|
100000 50000 41 89 12 33 73 79 38 48 90 68 ... |
correct output |
---|
4 1 21 1 2 2 1 1 3 2 3 7 6 20 ... |
user output |
---|
4 1 21 1 2 2 1 1 3 2 3 7 6 20 ... |
Test 19
Verdict: ACCEPTED
input |
---|
100000 100000 4325 2304 2625 9099 4244 1618 ... |
correct output |
---|
9994 5 9994 9994 9994 1 9994 9... |
user output |
---|
9994 5 9994 9994 9994 1 9994 9... |
Test 20
Verdict: ACCEPTED
input |
---|
100000 100 68725 58766 50437 78768 4415 2... |
correct output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
user output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |