| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 28525 | 이제 내가 두목이다~ (#68) | Play Onwards (FXCUP2_onward) | C++98 | 1000 ms | 2032 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 <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
vector<int> adj[202];
int dic[202];
string str[202];
bool flag = true;
void dfs(int x, int c)
{
    if(dic[x] != c && dic[x] != 0) flag = false;
    if(dic[x] == c) return;
    if(!flag) return;
    dic[x] = c;
    for(int nxt : adj[x])
    {
        dfs(nxt, c == 1 ? 2 : 1);
    }
}
int asdf(string s, string t, int k)
{
    for(int i=0; i<s.size()-k+1; i++)
    {
        string a = s.substr(i, k);
        if(t.find(a) != -1) return 1;
    }
    return 0;
}
int main()
{
    int n, k; cin >> n >> k;
	for(int i=0; i<n; i++)
    {
        cin >> str[i];
    }
    for(int i=0; i<n; i++)
    {
        for(int j=i+1; j<n; j++)
        {
            if(asdf(str[i], str[j], k) || asdf(str[j], str[i], k))
            {
                adj[j].push_back(i);
                adj[i].push_back(j);
            }
        }
    }
    for(int i=0; i<n; i++)
    {
        if(dic[i] == 0) dfs(i, 1);
    }
    if(flag)
    {
        cout << "Yes\n";
        for(int i=0; i<n; i++) cout << dic[i] << endl;
    }
    else cout << "No\n";
	return 0;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
