답안 #11841

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
11841 2014-12-12T06:44:14 Z gs14004 백신 (KOI13_vaccine) C++
0 / 24
28 ms 4524 KB
#include <cstdio>
#include <algorithm>
#include <set>
using namespace std;

set<long long> hash_virus[101];

long long chash[1005];
int n,k;

int fnd(long long x){
    for (int i=1; i<n; i++) {
        if(hash_virus[i].find(x) == hash_virus[i].end()) return 0;
    }
    return 1;
}

int main(){
    int n,k;
    scanf("%d %d",&n,&k);
    chash[0] = 1;
    for (int i=1; i<=k; i++) {
        chash[i] = chash[i-1] * 10007;
    }
    for (int i=0; i<n; i++) {
        int m, a[1005] ={};
        scanf("%d",&m);
        for (int j=0; j<m; j++) {
            scanf("%d",&a[j]);
        }
        long long ch = 0;
        for (int j=0; j<m; j++) {
            ch *= 10007;
            ch += a[j];
            if(j+1 >= k){
                hash_virus[i].insert(ch);
                ch -= a[j-k+1] * chash[k];
            }
        }
        reverse(a,a+m);
        ch = 0;
        for (int j=0; j<m; j++) {
            ch *= 10007;
            ch += a[j];
            if(j+1 >= k){
                hash_virus[i].insert(ch);
                ch -= a[j-k+1] * chash[k];
            }
        }
    }
    set<long long> ::iterator it = hash_virus[0].begin();
    while (it != hash_virus[0].end()) {
        if(fnd(*it)){
            puts("YES");
            return 0;
        }
        it++;
    }
    puts("NO");
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1224 KB Output is correct
2 Correct 0 ms 1224 KB Output is correct
3 Correct 0 ms 1224 KB Output is correct
4 Correct 0 ms 1224 KB Output is correct
5 Incorrect 0 ms 1224 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1224 KB Output is correct
2 Correct 0 ms 1224 KB Output is correct
3 Correct 0 ms 1224 KB Output is correct
4 Incorrect 0 ms 1224 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1224 KB Output is correct
2 Correct 0 ms 1224 KB Output is correct
3 Correct 0 ms 1224 KB Output is correct
4 Correct 0 ms 1224 KB Output is correct
5 Incorrect 0 ms 1224 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1224 KB Output is correct
2 Correct 0 ms 1356 KB Output is correct
3 Correct 0 ms 1356 KB Output is correct
4 Incorrect 0 ms 1224 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1620 KB Output is correct
2 Correct 8 ms 2148 KB Output is correct
3 Correct 8 ms 2544 KB Output is correct
4 Incorrect 20 ms 4524 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 3204 KB Output is correct
2 Correct 28 ms 4524 KB Output is correct
3 Correct 28 ms 4392 KB Output is correct
4 Incorrect 4 ms 3204 KB Output isn't correct
5 Halted 0 ms 0 KB -