Submission #28775

#TimeUsernameProblemLanguageResultExecution timeMemory
28775kriiiPlay Onwards (FXCUP2_onward)C++14
1 / 1
9 ms1980 KiB
#include <stdio.h> #include <queue> using namespace std; int N,K,C[202]; char S[202][22]; bool g[202][202]; int main() { scanf ("%d %d",&N,&K); for (int i=0;i<N;i++) scanf ("%s",S[i]); for (int i=0;i<N;i++) for (int j=i+1;j<N;j++){ bool d = 0; for (int p=K-1;S[i][p];p++) for (int q=K-1;S[j][q];q++){ bool n = 1; for (int r=0;r<K;r++) if (S[i][p-r] != S[j][q-r]){n = 0; break;} if (n) d = 1; } g[i][j] = g[j][i] = d; } int u = 0; for (int i=0;i<N;i++) if (C[i] == 0){ queue<int> Q; Q.push(i); C[i] = u+1; u = !u; while (!Q.empty()){ int x = Q.front(); Q.pop(); for (int y=0;y<N;y++) if (g[x][y]){ if (C[y] == 0){ Q.push(y); C[y] = 3 - C[x]; } if (C[x] + C[y] != 3){ puts("No"); return 0; } } } } puts("Yes"); for (int i=0;i<N;i++) printf ("%d\n",C[i]); return 0; }

Compilation message (stderr)

onward.cpp: In function 'int main()':
onward.cpp:10:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf ("%d %d",&N,&K);
                       ^
onward.cpp:11:41: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (int i=0;i<N;i++) scanf ("%s",S[i]);
                                         ^
#Verdict Execution timeMemoryGrader output
Fetching results...