# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
28565 | 2017-07-16T07:26:14 Z | Shocking Hot(#1200, khsoo01) | Play Onwards (FXCUP2_onward) | C++14 | 9 ms | 2296 KB |
#include<bits/stdc++.h> using namespace std; int n, k, l[205], vis[205], c[3]; char a[205][25]; vector<int> adj[205]; void solve (int I, int C) { if(vis[I]) return; vis[I] = C; c[C]++; for(auto &T : adj[I]) solve(T, ((C-1)^1)+1); } int main() { scanf("%d%d",&n,&k); for(int i=1;i<=n;i++) { scanf("%s",a[i]+1); l[i] = strlen(a[i]+1); } for(int i=1;i<=n;i++) for(int j=i+1;j<=n;j++) { if(l[i] < k || l[j] < k) continue; bool flag = 0; for(int A=1;A+k-1<=l[i];A++) { for(int B=1;B+k-1<=l[j];B++) { bool s = 0; for(int C=0;C<k;C++) { if(a[i][A+C] != a[j][B+C]) {s = true; break;} } if(!s) {flag = true; break;} } if(flag) break; } if(flag) { adj[i].push_back(j); adj[j].push_back(i); } } for(int i=1;i<=n;i++) solve(i, 1); for(int i=1;i<=n;i++) { for(auto &T : adj[i]) if(vis[i] == vis[T]) {puts("No"); return 0;} } puts("Yes"); printf("%d\n",1+(c[1]==n)); for(int i=2;i<=n;i++) printf("%d\n",vis[i]); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2032 KB | Output is correct |
2 | Correct | 0 ms | 2032 KB | Output is correct |
3 | Correct | 0 ms | 2032 KB | Output is correct |
4 | Correct | 0 ms | 2032 KB | Output is correct |
5 | Correct | 0 ms | 2296 KB | Output is correct |
6 | Correct | 0 ms | 2296 KB | Output is correct |
7 | Correct | 6 ms | 2032 KB | Output is correct |
8 | Correct | 3 ms | 2032 KB | Output is correct |
9 | Correct | 6 ms | 2032 KB | Output is correct |
10 | Correct | 6 ms | 2032 KB | Output is correct |
11 | Correct | 0 ms | 2032 KB | Output is correct |
12 | Correct | 9 ms | 2032 KB | Output is correct |
13 | Correct | 9 ms | 2032 KB | Output is correct |
14 | Correct | 3 ms | 2032 KB | Output is correct |
15 | Correct | 0 ms | 2032 KB | Output is correct |
16 | Correct | 0 ms | 2032 KB | Output is correct |
17 | Correct | 0 ms | 2032 KB | Output is correct |
18 | Correct | 0 ms | 2032 KB | Output is correct |
19 | Correct | 3 ms | 2032 KB | Output is correct |
20 | Correct | 6 ms | 2032 KB | Output is correct |
21 | Correct | 3 ms | 2032 KB | Output is correct |