# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
28775 | 2017-07-17T07:35:08 Z | kriii | Play Onwards (FXCUP2_onward) | C++14 | 9 ms | 1980 KB |
#include <stdio.h> #include <queue> using namespace std; int N,K,C[202]; char S[202][22]; bool g[202][202]; int main() { scanf ("%d %d",&N,&K); for (int i=0;i<N;i++) scanf ("%s",S[i]); for (int i=0;i<N;i++) for (int j=i+1;j<N;j++){ bool d = 0; for (int p=K-1;S[i][p];p++) for (int q=K-1;S[j][q];q++){ bool n = 1; for (int r=0;r<K;r++) if (S[i][p-r] != S[j][q-r]){n = 0; break;} if (n) d = 1; } g[i][j] = g[j][i] = d; } int u = 0; for (int i=0;i<N;i++) if (C[i] == 0){ queue<int> Q; Q.push(i); C[i] = u+1; u = !u; while (!Q.empty()){ int x = Q.front(); Q.pop(); for (int y=0;y<N;y++) if (g[x][y]){ if (C[y] == 0){ Q.push(y); C[y] = 3 - C[x]; } if (C[x] + C[y] != 3){ puts("No"); return 0; } } } } puts("Yes"); for (int i=0;i<N;i++) printf ("%d\n",C[i]); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 1980 KB | Output is correct |
2 | Correct | 0 ms | 1980 KB | Output is correct |
3 | Correct | 0 ms | 1980 KB | Output is correct |
4 | Correct | 0 ms | 1980 KB | Output is correct |
5 | Correct | 0 ms | 1980 KB | Output is correct |
6 | Correct | 6 ms | 1980 KB | Output is correct |
7 | Correct | 6 ms | 1980 KB | Output is correct |
8 | Correct | 6 ms | 1980 KB | Output is correct |
9 | Correct | 6 ms | 1980 KB | Output is correct |
10 | Correct | 6 ms | 1980 KB | Output is correct |
11 | Correct | 0 ms | 1980 KB | Output is correct |
12 | Correct | 6 ms | 1980 KB | Output is correct |
13 | Correct | 9 ms | 1980 KB | Output is correct |
14 | Correct | 3 ms | 1980 KB | Output is correct |
15 | Correct | 0 ms | 1980 KB | Output is correct |
16 | Correct | 0 ms | 1980 KB | Output is correct |
17 | Correct | 0 ms | 1980 KB | Output is correct |
18 | Correct | 0 ms | 1980 KB | Output is correct |
19 | Correct | 3 ms | 1980 KB | Output is correct |
20 | Correct | 3 ms | 1980 KB | Output is correct |
21 | Correct | 3 ms | 1980 KB | Output is correct |