# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
28378 | 2017-07-16T05:06:14 Z | ㅁㄴㅇㄹ호(#1227, gs13105) | Play Onwards (FXCUP2_onward) | C++14 | 6 ms | 1444 KB |
#include <stdio.h> #include <cstdlib> #include <cstring> #include <algorithm> #include <numeric> #include <string> #include <vector> #include <tuple> using namespace std; vector<int> adj[200]; char arr[200][21]; int len[200]; int col[200]; bool dfs(int x, int c) { col[x] = c; for(int y : adj[x]) { if(col[y] == c) return 1; if(col[y] == 0) { if(dfs(y, 3-c)) return 1; } } return 0; } int main() { //freopen("in", "r", stdin); //freopen("out", "w", stdout); bool u, v; int n, k, i, j, a, b, c; scanf("%d%d", &n, &k); for(i = 0; i<n; i++) scanf("%s", arr[i]); for(i = 0; i<n; i++) len[i] = strlen(arr[i]); for(i = 0; i<n; i++) { for(j = i+1; j<n; j++) { /*if(len[i] == len[j]) { v = 1; for(a = 0; a<len[i]; a++) { if(arr[i][a] != arr[j][a]) { v = 0; break; } } if(v) continue; }*/ v = 1; for(a = 0; a<len[i]-k+1; a++) { for(b = 0; b<len[j]-k+1; b++) { u = 1; for(c = 0; c<k; c++) { if(arr[i][a+c] != arr[j][b+c]) { u = 0; break; } } if(u) { adj[i].push_back(j); adj[j].push_back(i); v = 0; break; } } if(!v) break; } } } int t = 1; for(i = 0; i<n; i++) { if(col[i] == 0) { if(dfs(i, t)) { printf("No"); return 0; } t = 3-t; } } printf("Yes\n"); for(i = 0; i<n; i++) printf("%d\n", col[i]); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 1180 KB | Output is correct |
2 | Correct | 0 ms | 1180 KB | Output is correct |
3 | Correct | 0 ms | 1180 KB | Output is correct |
4 | Correct | 0 ms | 1180 KB | Output is correct |
5 | Correct | 0 ms | 1444 KB | Output is correct |
6 | Correct | 0 ms | 1444 KB | Output is correct |
7 | Correct | 3 ms | 1180 KB | Output is correct |
8 | Correct | 3 ms | 1180 KB | Output is correct |
9 | Correct | 3 ms | 1180 KB | Output is correct |
10 | Correct | 3 ms | 1180 KB | Output is correct |
11 | Correct | 0 ms | 1180 KB | Output is correct |
12 | Correct | 6 ms | 1180 KB | Output is correct |
13 | Correct | 6 ms | 1180 KB | Output is correct |
14 | Correct | 3 ms | 1180 KB | Output is correct |
15 | Correct | 0 ms | 1180 KB | Output is correct |
16 | Correct | 0 ms | 1180 KB | Output is correct |
17 | Correct | 0 ms | 1180 KB | Output is correct |
18 | Correct | 0 ms | 1180 KB | Output is correct |
19 | Correct | 3 ms | 1180 KB | Output is correct |
20 | Correct | 3 ms | 1180 KB | Output is correct |
21 | Correct | 3 ms | 1180 KB | Output is correct |