제출 #28506

#제출 시각아이디문제언어결과실행 시간메모리
28506맞왜틀 맞왜틀 신나는노래~ 헤이! 나도한번 불러보자 (#68)Play Onwards (FXCUP2_onward)C++11
0 / 1
9 ms2212 KiB
#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) 메시지

onward.cpp: In function 'bool same(std::__cxx11::string, std::__cxx11::string)':
onward.cpp:13:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i+K-1 < s1.size();i++){
                          ^
onward.cpp:14:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j = 0; j+K-1 <s2.size();j++){
                              ^
onward.cpp: In function 'int main()':
onward.cpp:41:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&N,&K);
                        ^
onward.cpp:44:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%s",str);
                        ^
#Verdict Execution timeMemoryGrader output
Fetching results...