Submission #3138

# Submission time Handle Problem Language Result Execution time Memory
3138 2013-08-26T07:42:57 Z club4208 백신 (KOI13_vaccine) C++
0 / 24
0 ms 5540 KB
#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(){
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);

    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 time Memory Grader output
1 Runtime error 0 ms 5540 KB open (syscall #2) was called by the program (disallowed syscall)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 5540 KB open (syscall #2) was called by the program (disallowed syscall)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 5540 KB open (syscall #2) was called by the program (disallowed syscall)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 5540 KB open (syscall #2) was called by the program (disallowed syscall)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 5540 KB open (syscall #2) was called by the program (disallowed syscall)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 5540 KB open (syscall #2) was called by the program (disallowed syscall)
2 Halted 0 ms 0 KB -