| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 28453 | 일단아무거나적어놓은팀이름 (#68) | Play Onwards (FXCUP2_onward) | C++14 | 9 ms | 2292 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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");
        int cnt = 0;
        for(int i = 0; i < n; ++i) cnt += chk[i] == 1;
        if(cnt == n) chk[n - 1] = 2;
        for(int i = 0; i < n; ++i) printf("%d\n", chk[i]);
    } else puts("No");
    return 0;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
