# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
28254 | 2017-07-16T04:12:08 Z | Sorry AcornCkiGuiziTeam(#1226, gs13068) | Play Onwards (FXCUP2_onward) | C++14 | 29 ms | 1448 KB |
#include <cstdio> #include <cstring> #include <vector> using namespace std; char a[202][24]; int b[202]; vector<int> g[202]; int v[202], c[202]; int f(int x, int z) { if (v[x]) return c[x] != z; v[x] = 1; c[x] = z; for (auto t : g[x]) if (f(t, z ^ 1)) return 1; return 0; } int main() { int i, j, k, l, n, m, t; scanf("%d%d", &n, &m); for (i = 0; i < n; i++) { scanf("%s", a[i]); b[i] = strlen(a[i]); } for (i = 0; i < n; i++) for (j = 0; j < i; j++) { for (k = -20; k <= 20; k++) { t = 0; for (l = 0; l < b[i]; l++) { if (l + k >= 0 && l + k < b[j] && a[i][l] == a[j][l + k]) t++; else t = 0; if (t >= m) break; } if (l < b[i]) break; } if (k <= 20) { g[i].push_back(j); g[j].push_back(i); } } j = 1; for (i = 0; i < n; i++) { if (!v[i] && f(i, 0)) { puts("No"); return 0; } if (c[i]) j = 0; } puts("Yes"); for (i = 0; i < n; i++) printf("%d\n", (j ? i == 0 : c[i]) + 1); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 1184 KB | Output is correct |
2 | Correct | 0 ms | 1184 KB | Output is correct |
3 | Correct | 0 ms | 1184 KB | Output is correct |
4 | Correct | 0 ms | 1184 KB | Output is correct |
5 | Correct | 13 ms | 1448 KB | Output is correct |
6 | Correct | 6 ms | 1448 KB | Output is correct |
7 | Correct | 16 ms | 1184 KB | Output is correct |
8 | Correct | 19 ms | 1184 KB | Output is correct |
9 | Correct | 16 ms | 1184 KB | Output is correct |
10 | Correct | 16 ms | 1184 KB | Output is correct |
11 | Correct | 26 ms | 1184 KB | Output is correct |
12 | Correct | 29 ms | 1184 KB | Output is correct |
13 | Correct | 19 ms | 1184 KB | Output is correct |
14 | Correct | 23 ms | 1184 KB | Output is correct |
15 | Correct | 0 ms | 1184 KB | Output is correct |
16 | Correct | 0 ms | 1184 KB | Output is correct |
17 | Correct | 0 ms | 1184 KB | Output is correct |
18 | Correct | 13 ms | 1184 KB | Output is correct |
19 | Correct | 16 ms | 1184 KB | Output is correct |
20 | Correct | 16 ms | 1184 KB | Output is correct |
21 | Correct | 16 ms | 1184 KB | Output is correct |