Submission #28546

#TimeUsernameProblemLanguageResultExecution timeMemory
28546Shocking Hot (#68)Play Onwards (FXCUP2_onward)C++14
0 / 1
0 ms2032 KiB
#include<bits/stdc++.h> using namespace std; int n, k, c1[26], c2[26], mat, l[205], vis[205]; char a[205][25]; vector<int> adj[205]; void upd (int P, int V, int C1[], int C2[]) { if(C1[P] == C2[P]) mat--; C1[P] += V; if(C1[P] == C2[P]) mat++; } void solve (int I, int C) { if(vis[I]) return; vis[I] = C; for(auto &T : adj[I]) solve(T, ((C-1)^1)+1); } int main() { scanf("%d%d",&n,&k); for(int i=1;i<=n;i++) { scanf("%s",a[i]+1); l[i] = strlen(a[i]+1); } for(int i=1;i<=n;i++) { for(int j=i+1;j<=n;j++) { if(l[i] < k || l[j] < k) continue; bool flag = 0; for(int A=k;A<=l[i];A++) { for(int X=0;X<26;X++) {c1[X] = 0; c2[X] = 0;} mat = 26; for(int X=A-k+1;X<=A;X++) upd(a[i][X]-'a', 1, c1, c2); for(int X=1;X<k;X++) upd(a[j][X]-'a', 1, c2, c1); for(int X=k;X<=l[j];X++) { upd(a[j][X]-'a', 1, c2, c1); if(mat == 26) {flag = true; break;} upd(a[j][X-k+1]-'a', -1, c2, c1); } if(flag) break; } if(flag) { adj[i].push_back(j); adj[j].push_back(i); } } } for(int i=1;i<=n;i++) solve(i, 1); for(int i=1;i<=n;i++) { for(auto &T : adj[i]) if(vis[i] == vis[T]) {puts("No"); return 0;} } puts("Yes"); for(int i=1;i<=n;i++) printf("%d\n",vis[i]); }

Compilation message (stderr)

onward.cpp: In function 'int main()':
onward.cpp:22:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&k);
                     ^
onward.cpp:24:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%s",a[i]+1);
                     ^
#Verdict Execution timeMemoryGrader output
Fetching results...