제출 #28446

#제출 시각아이디문제언어결과실행 시간메모리
28446일단아무거나적어놓은팀이름 (#68)Play Onwards (FXCUP2_onward)C++14
0 / 1
6 ms2292 KiB
#include<cstdio> #include<iostream> #include<vector> #include<cstring> using namespace std; vector<int> adj[201]; int n, k, len[201], chk[201]; char s[201][21]; bool possible = 1; void f(int u, int c) { if(!possible) return; if(chk[u]) { if(chk[u] != c) possible = 0; return; } chk[u] = c; for(int t : adj[u]) f(t, c == 1 ? 2 : 1); } void check(int a, int b) { if(len[a] < k || len[b] < k) return; bool ok = 0; for(int i = 0; i < len[a] - k + 1; ++i) { for(int j = 0; j < len[b] - k + 1; ++j) { bool flag = 1; for(int t = 0; t < k; ++t) { if(s[a][i + t] != s[b][j + t]) { flag = 0; break; } } if(flag) { ok = 1; break; } } if(ok) break; } if(ok) { adj[a].push_back(b); adj[b].push_back(a); } } int main() { scanf("%d%d", &n, &k); for(int i = 0; i < n; ++i) scanf("%s", s[i]), len[i] = (int)strlen(s[i]); for(int i = 0; i < n; ++i) for(int j = i + 1; j < n; ++j) check(i, j); for(int i = 0; i < n; ++i) if(!chk[i]) f(i, 1); if(possible) { puts("Yes"); for(int i = 0; i < n; ++i) printf("%d\n", chk[i]); } else puts("No"); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

onward.cpp: In function 'int main()':
onward.cpp:44:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &n, &k);
                          ^
onward.cpp:46:54: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%s", s[i]), len[i] = (int)strlen(s[i]);
                                                      ^
#Verdict Execution timeMemoryGrader output
Fetching results...