| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 28254 | Sorry AcornCkiGuiziTeam (#68) | Play Onwards (FXCUP2_onward) | C++14 | 29 ms | 1448 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 <cstring>
#include <vector>
using namespace std;
char a[202][24];
int b[202];
vector<int> g[202];
int v[202], c[202];
int f(int x, int z) {
	if (v[x]) return c[x] != z;
	v[x] = 1;
	c[x] = z;
	for (auto t : g[x]) if (f(t, z ^ 1)) return 1;
	return 0;
}
int main() {
	int i, j, k, l, n, m, t;
	scanf("%d%d", &n, &m);
	for (i = 0; i < n; i++) {
		scanf("%s", a[i]);
		b[i] = strlen(a[i]);
	}
	for (i = 0; i < n; i++) for (j = 0; j < i; j++) {
		for (k = -20; k <= 20; k++) {
			t = 0;
			for (l = 0; l < b[i]; l++) {
				if (l + k >= 0 && l + k < b[j] && a[i][l] == a[j][l + k]) t++;
				else t = 0;
				if (t >= m) break;
			}
			if (l < b[i]) break;
		}
		if (k <= 20) {
			g[i].push_back(j);
			g[j].push_back(i);
		}
	}
	j = 1;
	for (i = 0; i < n; i++) {
		if (!v[i] && f(i, 0)) {
			puts("No");
			return 0;
		}
		if (c[i]) j = 0;
	}
	puts("Yes");
	for (i = 0; i < n; i++) printf("%d\n", (j ? i == 0 : c[i]) + 1);
	return 0;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
