# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
28446 | 2017-07-16T06:01:55 Z | 일단아무거나적어놓은팀이름(#1191, solarmagic, junodeveloper) | Play Onwards (FXCUP2_onward) | C++14 | 6 ms | 2292 KB |
#include<cstdio> #include<iostream> #include<vector> #include<cstring> using namespace std; vector<int> adj[201]; int n, k, len[201], chk[201]; char s[201][21]; bool possible = 1; void f(int u, int c) { if(!possible) return; if(chk[u]) { if(chk[u] != c) possible = 0; return; } chk[u] = c; for(int t : adj[u]) f(t, c == 1 ? 2 : 1); } void check(int a, int b) { if(len[a] < k || len[b] < k) return; bool ok = 0; for(int i = 0; i < len[a] - k + 1; ++i) { for(int j = 0; j < len[b] - k + 1; ++j) { bool flag = 1; for(int t = 0; t < k; ++t) { if(s[a][i + t] != s[b][j + t]) { flag = 0; break; } } if(flag) { ok = 1; break; } } if(ok) break; } if(ok) { adj[a].push_back(b); adj[b].push_back(a); } } int main() { scanf("%d%d", &n, &k); for(int i = 0; i < n; ++i) scanf("%s", s[i]), len[i] = (int)strlen(s[i]); for(int i = 0; i < n; ++i) for(int j = i + 1; j < n; ++j) check(i, j); for(int i = 0; i < n; ++i) if(!chk[i]) f(i, 1); if(possible) { puts("Yes"); for(int i = 0; i < n; ++i) printf("%d\n", chk[i]); } else puts("No"); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2028 KB | Output is correct |
2 | Correct | 0 ms | 2028 KB | Output is correct |
3 | Correct | 0 ms | 2028 KB | Output is correct |
4 | Correct | 0 ms | 2028 KB | Output is correct |
5 | Correct | 0 ms | 2292 KB | Output is correct |
6 | Correct | 0 ms | 2292 KB | Output is correct |
7 | Correct | 6 ms | 2028 KB | Output is correct |
8 | Correct | 6 ms | 2028 KB | Output is correct |
9 | Correct | 3 ms | 2028 KB | Output is correct |
10 | Correct | 3 ms | 2028 KB | Output is correct |
11 | Incorrect | 0 ms | 2028 KB | Output isn't correct |
12 | Halted | 0 ms | 0 KB | - |