Submission #1691978
Source Code Expand
#include <cstdio> #define iter(i, n) for (int i = 1; i <= n; ++i) #define iter_e(i, x) for (int i = pos[x]; i; i = g[i].frt) #define NR 101000 typedef long long i64; struct Edge { int y, frt; } g[NR * 2]; int n, m, pos[NR], gsz, cnt_e, col[NR]; i64 cnt[3], ans; bool invalid; void AE(int x, int y) { g[++gsz] = (Edge) { y, pos[x] }, pos[x] = gsz; } #define v g[i].y void dfs(int x) { ++cnt[col[x]]; iter_e(i, x) { int c = (col[x] + (i % 2 == 1 ? 1 : 2)) % 3; if (col[v] == -1) col[v] = c, dfs(v); else if (col[v] != c) invalid = true; ++cnt_e; } } int main() { scanf("%d%d", &n, &m); iter(i, m) { int x, y; scanf("%d%d", &x, &y); AE(x, y), AE(y, x); } iter(i, n) col[i] = -1; iter(i, n) if (col[i] == -1) { cnt[0] = cnt[1] = cnt[2] = cnt_e = 0; col[i] = 0; invalid = false; dfs(i); //if (cnt[0] + cnt[1] + cnt[2] > 2) printf("%d %lld %lld %lld %d\n", invalid, cnt[0], cnt[1], cnt[2], cnt_e/2); if (invalid) ans += (cnt[0] + cnt[1] + cnt[2]) * (cnt[0] + cnt[1] + cnt[2]); else if (cnt[1] != 0 && cnt[2] != 0) ans += cnt[0] * cnt[1] + cnt[1] * cnt[2] + cnt[2] * cnt[0]; else ans += cnt_e / 2; } printf("%lld\n", ans); return 0; }
Submission Info
Submission Time | |
---|---|
Task | F - Black Radius |
User | Ketsui |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1227 Byte |
Status | RE |
Exec Time | 2103 ms |
Memory | 2688 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:29:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d%d", &n, &m); ^ ./Main.cpp:32:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d%d", &x, &y); ^
Judge Result
Set Name | Sample | Subtask | All | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 1300 | 0 / 600 | ||||||||||||||
Status |
|
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt |
Subtask | 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, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt, 1_24.txt, 1_25.txt, 1_26.txt, 1_27.txt, 1_28.txt, 1_29.txt |
All | 0_00.txt, 0_01.txt, 0_02.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, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt, 1_24.txt, 1_25.txt, 1_26.txt, 1_27.txt, 1_28.txt, 1_29.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, 2_44.txt, 2_45.txt, 2_46.txt, 2_47.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | WA | 1 ms | 128 KB |
0_01.txt | WA | 1 ms | 128 KB |
0_02.txt | WA | 1 ms | 128 KB |
1_00.txt | WA | 1 ms | 128 KB |
1_01.txt | WA | 21 ms | 2176 KB |
1_02.txt | RE | 117 ms | 2176 KB |
1_03.txt | RE | 117 ms | 2176 KB |
1_04.txt | TLE | 2103 ms | 2560 KB |
1_05.txt | TLE | 2103 ms | 1408 KB |
1_06.txt | RE | 120 ms | 2176 KB |
1_07.txt | RE | 119 ms | 2176 KB |
1_08.txt | WA | 12 ms | 1536 KB |
1_09.txt | WA | 14 ms | 1792 KB |
1_10.txt | RE | 119 ms | 2176 KB |
1_11.txt | RE | 123 ms | 2176 KB |
1_12.txt | WA | 6 ms | 1280 KB |
1_13.txt | RE | 119 ms | 2176 KB |
1_14.txt | WA | 20 ms | 2304 KB |
1_15.txt | RE | 120 ms | 2176 KB |
1_16.txt | WA | 14 ms | 1664 KB |
1_17.txt | WA | 9 ms | 1408 KB |
1_18.txt | WA | 5 ms | 1280 KB |
1_19.txt | WA | 13 ms | 1664 KB |
1_20.txt | RE | 123 ms | 2176 KB |
1_21.txt | RE | 120 ms | 2176 KB |
1_22.txt | RE | 120 ms | 2176 KB |
1_23.txt | RE | 119 ms | 2176 KB |
1_24.txt | WA | 97 ms | 1920 KB |
1_25.txt | WA | 889 ms | 1920 KB |
1_26.txt | WA | 4 ms | 1280 KB |
1_27.txt | RE | 123 ms | 2176 KB |
1_28.txt | WA | 14 ms | 1792 KB |
1_29.txt | WA | 13 ms | 1792 KB |
2_00.txt | WA | 1 ms | 128 KB |
2_01.txt | RE | 121 ms | 2176 KB |
2_02.txt | WA | 4 ms | 1280 KB |
2_03.txt | TLE | 2103 ms | 1920 KB |
2_04.txt | RE | 121 ms | 2176 KB |
2_05.txt | TLE | 2103 ms | 2560 KB |
2_06.txt | RE | 120 ms | 2176 KB |
2_07.txt | WA | 12 ms | 1536 KB |
2_08.txt | RE | 119 ms | 2176 KB |
2_09.txt | TLE | 2103 ms | 2176 KB |
2_10.txt | TLE | 2103 ms | 2688 KB |
2_11.txt | WA | 338 ms | 1408 KB |
2_12.txt | WA | 1453 ms | 1408 KB |
2_13.txt | RE | 118 ms | 2176 KB |
2_14.txt | WA | 274 ms | 1280 KB |
2_15.txt | RE | 116 ms | 2176 KB |
2_16.txt | RE | 118 ms | 2176 KB |
2_17.txt | WA | 9 ms | 1408 KB |
2_18.txt | WA | 11 ms | 1408 KB |
2_19.txt | WA | 6 ms | 1280 KB |
2_20.txt | WA | 7 ms | 1152 KB |
2_21.txt | RE | 116 ms | 2176 KB |
2_22.txt | WA | 14 ms | 1792 KB |
2_23.txt | WA | 8 ms | 1280 KB |
2_24.txt | RE | 117 ms | 2176 KB |
2_25.txt | RE | 116 ms | 2176 KB |
2_26.txt | WA | 13 ms | 1664 KB |
2_27.txt | WA | 4 ms | 1280 KB |
2_28.txt | WA | 3 ms | 1280 KB |
2_29.txt | WA | 25 ms | 2432 KB |
2_30.txt | WA | 14 ms | 1664 KB |
2_31.txt | WA | 5 ms | 1280 KB |
2_32.txt | WA | 13 ms | 1792 KB |
2_33.txt | WA | 15 ms | 1792 KB |
2_34.txt | WA | 4 ms | 1280 KB |
2_35.txt | WA | 10 ms | 1536 KB |
2_36.txt | RE | 115 ms | 2176 KB |
2_37.txt | TLE | 2103 ms | 2048 KB |
2_38.txt | RE | 116 ms | 2176 KB |
2_39.txt | RE | 116 ms | 2176 KB |
2_40.txt | RE | 115 ms | 2176 KB |
2_41.txt | WA | 212 ms | 2560 KB |
2_42.txt | RE | 116 ms | 2176 KB |
2_43.txt | RE | 115 ms | 2176 KB |
2_44.txt | TLE | 2103 ms | 2432 KB |
2_45.txt | RE | 115 ms | 2176 KB |
2_46.txt | RE | 115 ms | 2176 KB |
2_47.txt | WA | 1207 ms | 1792 KB |