# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
28336 | 뚜루루뚜루 (#68) | Play Onwards (FXCUP2_onward) | C++98 | 0 ms | 2068 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 <bits/stdc++.h>
using namespace std;
char str[209][22];
bool adj[209][209];
int res[209];
int main()
{
int n,k;
scanf("%d %d",&n,&k);
for(int i=0; i<n; i++) scanf(" %s",str[i]);
for(int i=0; i<n; i++) {
for(int j=i+1; j<n; j++) {
int ilen = strlen(str[i]);
int jlen = strlen(str[j]);
for(int x=0; x<=ilen-k; x++) {
for(int y=0; y<=jlen-k; y++) {
int p;
for(p=0; p<k; p++) if(str[i][x+p] != str[j][y+p]) break;
if(p==k) {
adj[i][j] = 1;
goto stop;
}
}
}
stop:;
}
}
res[0] = 1;
for(int i=0; i<n; i++) {
for(int j=i+1; j<n; j++) {
if(adj[i][j] == 0) continue;
int tmp = 3 - res[i];
if(res[j] != 0 && res[j] != tmp) return !printf("No");
res[j] = tmp;
}
}
puts("Yes");
for(int i=0; i<n; i++) {
if(res[i] == 0) puts("1");
else printf("%d\n",res[i]);
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |