# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
28506 | 맞왜틀 맞왜틀 신나는노래~ 헤이! 나도한번 불러보자 (#68) | Play Onwards (FXCUP2_onward) | C++11 | 9 ms | 2212 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <cstdio>
#include <string.h>
#include <cstdio>
#include <vector>
#include <queue>
#include <memory.h>
#include <string>
#include <cstdlib>
std::string s[300];
int N, K;
std::vector<int> G[300];
bool same(std::string s1, std::string s2){
for(int i = 0; i+K-1 < s1.size();i++){
for(int j = 0; j+K-1 <s2.size();j++){
int flag = true;
for(int k =0; k < K;k++){
flag &= s1[i+k] == s2[j+k];
}
if(flag) return true;
}
}
return false;
}
int color[300];
void dfs(int idx, int c){
if(color[idx] != -1){
if(color[idx] == c) return;
else {
printf("No\n");
exit(0);
}
}
color[idx] = c;
for(auto i : G[idx]){
dfs(i,!c);
}
}
int main(){
memset(color,-1,sizeof(color));
scanf("%d%d",&N,&K);
for(int i =0 ; i <N;i++){
char str[100];
scanf("%s",str);
s[i] = str;
}
for(int i = 0; i < N; i++){
for(int j = i+1; j < N; j++){
if(same(s[i],s[j]))
{
G[i].push_back(j);
G[j].push_back(i);
}
}
}
for(int i = 0; i < N; i++){
if(color[i] == -1) dfs(i,0);
}
printf("Yes\n");
for(int i =0; i < N; i++){
printf("%d\n",color[i]+1);
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |