# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
28356 | ㅁㄴㅇㄹ호 (#68) | Play Onwards (FXCUP2_onward) | C++14 | 0 ms | 1180 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <stdio.h>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <vector>
#include <tuple>
using namespace std;
vector<int> adj[200];
char arr[200][21];
int len[200];
int col[200];
bool dfs(int x, int c)
{
col[x] = c;
for(int y : adj[x])
{
if(col[y] == c)
return 1;
if(col[y] == 0)
{
if(dfs(y, 3-c))
return 1;
}
}
return 0;
}
int main()
{
//freopen("in", "r", stdin);
//freopen("out", "w", stdout);
bool u, v;
int n, k, i, j, a, b, c;
scanf("%d%d", &n, &k);
for(i = 0; i<n; i++)
scanf("%s", arr[i]);
for(i = 0; i<n; i++)
len[i] = strlen(arr[i]);
for(i = 0; i<n; i++)
{
for(j = i+1; j<n; j++)
{
v = 1;
for(a = 0; a<len[i]-k+1; a++)
{
for(b = 0; b<len[j]-k+1; b++)
{
u = 1;
for(c = 0; c<k; c++)
{
if(arr[i][a+c] != arr[j][b+c])
{
u = 0;
break;
}
}
if(u)
{
adj[i].push_back(j);
adj[j].push_back(i);
v = 0;
break;
}
}
if(!v)
break;
}
}
}
for(i = 0; i<n; i++)
{
if(col[i] == 0)
{
if(dfs(i, 1))
{
printf("NO");
return 0;
}
}
}
printf("Yes\n");
for(i = 0; i<n; i++)
printf("%d\n", col[i]);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |