| Task: | Tietoverkko |
| Sender: | Katajisto |
| Submission time: | 2019-01-04 17:27:46 +0200 |
| Language: | C++ |
| Status: | READY |
| Result: | 0 |
| group | verdict | score |
|---|---|---|
| #1 | WRONG ANSWER | 0 |
| #2 | WRONG ANSWER | 0 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | ACCEPTED | 0.02 s | 1 | details |
| #2 | WRONG ANSWER | 0.02 s | 1 | details |
| #3 | WRONG ANSWER | 0.03 s | 1 | details |
| #4 | WRONG ANSWER | 0.03 s | 1 | details |
| #5 | WRONG ANSWER | 0.01 s | 1 | details |
| #6 | ACCEPTED | 0.15 s | 2 | details |
| #7 | WRONG ANSWER | 0.14 s | 2 | details |
| #8 | WRONG ANSWER | 0.13 s | 2 | details |
| #9 | WRONG ANSWER | 0.14 s | 2 | details |
| #10 | WRONG ANSWER | 0.16 s | 2 | details |
Compiler report
input/code.cpp: In function 'int main()':
input/code.cpp:51:7: warning: unused variable 'oc_f' [-Wunused-variable]
int oc_f = f;
^~~~Code
#include<bits/stdc++.h>
using namespace std;
vector<int> v[101010];
bool z[101010];
int p[101010];
bool zz[101010];
bool found = false;
int f;
int gg;
int haku2(int n,int g) {
//cout << n << "::" << g << "\n";
if(n == g) {
//cout << found << "\n";
return 1;
}
if(zz[n] == true) return -1e6;
zz[n] = true;
int mx = -1e6;
for(int i : v[n]) {
mx = max(haku2(i,g)+1,mx);
}
//cout << mx << "\n";
return mx;
}
void haku(int n, int pp) {
//cout << n << " :: " << pp << endl;
if(z[n]) {found = true; f = n; gg = pp; return;}
z[n] = true;
p[n] = pp;
for(int u : v[n]) {
if(u != pp) haku(u, n);
}
}
int main() {
for(int i=0; i < 101010; i++) z[i] = false;
int n;
cin >> n;
for(int i = 0; i < n; i++) {
int a, b; cin >> a >> b;
v[a].push_back(b);
v[b].push_back(a);
}
haku(1,1);
int cc = 1;
int oc_f = f;
f = p[f];
if(found) {
cc = haku2(f,gg);
cout << n-cc;
}
else cout << n;
}
Test details
Test 1
Group: 1
Verdict: ACCEPTED
| input |
|---|
| 100 16 88 6 77 60 92 98 64 ... |
| correct output |
|---|
| 97 |
| user output |
|---|
| 97 |
Test 2
Group: 1
Verdict: WRONG ANSWER
| input |
|---|
| 100 97 41 95 93 79 60 5 4 ... |
| correct output |
|---|
| 95 |
| user output |
|---|
| 96 |
Test 3
Group: 1
Verdict: WRONG ANSWER
| input |
|---|
| 100 87 24 21 49 86 85 42 32 ... |
| correct output |
|---|
| 90 |
| user output |
|---|
| 91 |
Test 4
Group: 1
Verdict: WRONG ANSWER
| input |
|---|
| 100 30 24 54 79 51 6 80 29 ... |
| correct output |
|---|
| 50 |
| user output |
|---|
| 51 |
Test 5
Group: 1
Verdict: WRONG ANSWER
| input |
|---|
| 100 11 27 54 59 100 90 2 95 ... |
| correct output |
|---|
| 0 |
| user output |
|---|
| 1 |
Test 6
Group: 2
Verdict: ACCEPTED
| input |
|---|
| 100000 98276 76171 70684 49183 48756 661 17166 16972 ... |
| correct output |
|---|
| 99997 |
| user output |
|---|
| 99997 |
Test 7
Group: 2
Verdict: WRONG ANSWER
| input |
|---|
| 100000 35903 47275 13566 84 58018 42495 57071 4451 ... |
| correct output |
|---|
| 99995 |
| user output |
|---|
| 99996 |
Test 8
Group: 2
Verdict: WRONG ANSWER
| input |
|---|
| 100000 79209 94485 60266 86793 27501 19927 13544 59730 ... |
| correct output |
|---|
| 99000 |
| user output |
|---|
| 99001 |
Test 9
Group: 2
Verdict: WRONG ANSWER
| input |
|---|
| 100000 68402 82703 12892 46068 60013 40753 26168 34434 ... |
| correct output |
|---|
| 90000 |
| user output |
|---|
| 90001 |
Test 10
Group: 2
Verdict: WRONG ANSWER
| input |
|---|
| 100000 37330 74855 54324 45726 61652 15611 79081 47339 ... |
| correct output |
|---|
| 0 |
| user output |
|---|
| 1 |
