Submission #1814835
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> pii; #define A first #define B second const int MAXN = 1e5+5; ll n, m, ans; vector<int> g[MAXN]; bool isc[MAXN]; pii dfs(int v, int f = -1) { pii tot = pii(0, 0); for (int u : g[v]) { if (isc[u] || u == f) continue; pii t = dfs(u, v); pii tot1 = tot; if (tot.A >= t.B) { tot.A -= t.B; t.B = 0; } else { t.B -= tot.A; tot.A = 0; } if (tot.B >= t.A) { tot.B -= t.A; t.A = 0; } else { t.A -= tot.B; tot.B = 0; } tot.A += t.A; tot.B += t.B; } if (tot.B >= 1) tot.B--; else tot.A = 1; ans += (tot.A + tot.B); swap(tot.A, tot.B); return tot; } int main() { cin >> n >> m; for (int i = 0; i < m; ++i) { int a, b; cin >> a >> b; a--; b--; g[a].push_back(b); g[b].push_back(a); } if (n%2 == 1) { cout << "-1\n"; return 0; } pii t = dfs(0, -1); if (t != pii(0, 0)) { cout << "-1\n"; return 0; } cout << ans << endl; }
Submission Info
Submission Time | |
---|---|
Task | F - Namori |
User | desert97 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1071 Byte |
Status | RE |
Exec Time | 2117 ms |
Memory | 268160 KB |
Judge Result
Set Name | Sample | Subtask1 | All | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 1500 | 0 / 700 | ||||||||||||||||
Status |
|
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt |
Subtask1 | 0_00.txt, 0_01.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt |
All | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 2_00.txt, 2_01.txt, 2_02.txt, 2_03.txt, 2_04.txt, 2_05.txt, 2_06.txt, 2_07.txt, 2_08.txt, 2_09.txt, 2_10.txt, 2_11.txt, 2_12.txt, 2_13.txt, 2_14.txt, 2_15.txt, 2_16.txt, 2_17.txt, 2_18.txt, 2_19.txt, 2_20.txt, 2_21.txt, 2_22.txt, 2_23.txt, 2_24.txt, 2_25.txt, 2_26.txt, 2_27.txt, 2_28.txt, 2_29.txt, 2_30.txt, 2_31.txt, 2_32.txt, 2_33.txt, 2_34.txt, 2_35.txt, 2_36.txt, 2_37.txt, 2_38.txt, 2_39.txt, 2_40.txt, 2_41.txt, 2_42.txt, 2_43.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | AC | 2 ms | 2560 KB |
0_01.txt | AC | 2 ms | 2560 KB |
0_02.txt | RE | 224 ms | 264704 KB |
0_03.txt | RE | 223 ms | 264704 KB |
1_00.txt | AC | 2 ms | 2560 KB |
1_01.txt | AC | 94 ms | 11776 KB |
1_02.txt | WA | 84 ms | 7680 KB |
1_03.txt | AC | 82 ms | 6136 KB |
1_04.txt | WA | 91 ms | 8576 KB |
1_05.txt | WA | 93 ms | 8320 KB |
1_06.txt | WA | 91 ms | 8320 KB |
1_07.txt | WA | 92 ms | 7680 KB |
1_08.txt | WA | 92 ms | 8832 KB |
1_09.txt | WA | 87 ms | 6016 KB |
1_10.txt | WA | 88 ms | 5888 KB |
1_11.txt | WA | 91 ms | 5888 KB |
1_12.txt | WA | 90 ms | 5760 KB |
1_13.txt | AC | 89 ms | 5760 KB |
1_14.txt | AC | 90 ms | 5888 KB |
1_15.txt | WA | 91 ms | 5760 KB |
1_16.txt | AC | 85 ms | 5760 KB |
1_17.txt | WA | 92 ms | 5760 KB |
2_00.txt | RE | 221 ms | 264704 KB |
2_01.txt | RE | 487 ms | 267904 KB |
2_02.txt | RE | 519 ms | 268032 KB |
2_03.txt | TLE | 2104 ms | 10616 KB |
2_04.txt | RE | 557 ms | 268032 KB |
2_05.txt | RE | 578 ms | 267904 KB |
2_06.txt | RE | 592 ms | 267904 KB |
2_07.txt | RE | 547 ms | 268032 KB |
2_08.txt | RE | 583 ms | 267904 KB |
2_09.txt | TLE | 2104 ms | 6272 KB |
2_10.txt | TLE | 2104 ms | 6016 KB |
2_11.txt | RE | 1495 ms | 268032 KB |
2_12.txt | TLE | 2104 ms | 5888 KB |
2_13.txt | AC | 87 ms | 5760 KB |
2_14.txt | TLE | 2117 ms | 231808 KB |
2_15.txt | TLE | 2106 ms | 39680 KB |
2_16.txt | AC | 87 ms | 5760 KB |
2_17.txt | RE | 422 ms | 267904 KB |
2_18.txt | AC | 2 ms | 2560 KB |
2_19.txt | RE | 479 ms | 268028 KB |
2_20.txt | TLE | 2104 ms | 10360 KB |
2_21.txt | RE | 482 ms | 267904 KB |
2_22.txt | RE | 527 ms | 268032 KB |
2_23.txt | RE | 560 ms | 268032 KB |
2_24.txt | RE | 594 ms | 267904 KB |
2_25.txt | RE | 530 ms | 268160 KB |
2_26.txt | RE | 577 ms | 267904 KB |
2_27.txt | TLE | 2104 ms | 15616 KB |
2_28.txt | RE | 797 ms | 268032 KB |
2_29.txt | TLE | 2104 ms | 6656 KB |
2_30.txt | TLE | 2104 ms | 5888 KB |
2_31.txt | AC | 87 ms | 5760 KB |
2_32.txt | TLE | 2114 ms | 185344 KB |
2_33.txt | TLE | 2105 ms | 23552 KB |
2_34.txt | AC | 86 ms | 5760 KB |
2_35.txt | TLE | 2106 ms | 56948 KB |
2_36.txt | TLE | 2104 ms | 7032 KB |
2_37.txt | TLE | 2104 ms | 7928 KB |
2_38.txt | TLE | 2104 ms | 7928 KB |
2_39.txt | TLE | 2104 ms | 7160 KB |
2_40.txt | TLE | 2104 ms | 7160 KB |
2_41.txt | TLE | 2104 ms | 7416 KB |
2_42.txt | TLE | 2104 ms | 7288 KB |
2_43.txt | TLE | 2104 ms | 6904 KB |