Submission #3139

#TimeUsernameProblemLanguageResultExecution timeMemory
3139club4208백신 (KOI13_vaccine)C++98
24 / 24
16 ms5548 KiB
#include <stdio.h> #include <algorithm> #include <queue> #include <vector> int dt[101][1001], n, k; int num[1001], hash1[10001], cn[10001]; int hash2[10001][101], chk[10001]; int main(){ scanf("%d %d", &n, &k); int i, j, l, a, cnt1, cnt2, flg=0; for(i=1;i<=n;i++){ scanf("%d", &num[i]); for(j=1;j<=num[i];j++){ scanf("%d", &dt[i][j]); a=dt[i][j]; if(hash2[a][i] == 0){ hash2[a][i]=1; cn[a]++; } } } for(i=1;i<=10000;i++){ if(cn[i] == n) chk[i]=1; } for(i=1;i<=num[1]-k+1;i++){ for(j=1;j<=10000;j++) hash1[j]=0; for(j=i;j<=i+k-1;j++){ if(!chk[dt[1][j]]) break; hash1[dt[1][j]]=1; } if(!chk[dt[1][j]] && j!=i+k) continue; cnt2=0; for(j=2;j<=n;j++){ cnt1=0; for(l=1;l<=num[j];l++){ if(hash1[dt[j][l]]==1) cnt1++; else cnt1=0; if(cnt1==k) break; } if(cnt1==k) cnt2++; } if(cnt2==n-1){ printf("YES"); flg=1; break; } } if(!flg) printf("NO"); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...