# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
28365 | 2017-07-16T05:01:45 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; } } } for(i = 0; i<n; i++) { if(col[i] == 0) { if(dfs(i, 1)) { printf("No"); return 0; } } } printf("Yes\n"); for(i = 0; i<n; i++) printf("%d\n", col[i]); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | 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 | 6 ms | 1180 KB | Output is correct |
11 | Incorrect | 0 ms | 1180 KB | Output isn't correct |
12 | Halted | 0 ms | 0 KB | - |