제출 #236973

#제출 시각아이디문제언어결과실행 시간메모리
236973PeppaPigGenetics (BOI18_genetics)C++14
100 / 100
321 ms33572 KiB
#include <bits/stdc++.h>

#define long long long

using namespace std;

const int N = 4105;
const int P = 98765431;

int n, m, k;
long mpow[N], hsh[N][4];
char S[N][N];

int f(char c) {
    if(c == 'A') return 0;
    if(c == 'T') return 1;
    if(c == 'C') return 2;
    return 3;
}

int main() {
    mpow[0] = 1;
    for(int i = 1; i < N; i++) mpow[i] = mpow[i - 1] * P;

    scanf("%d %d %d", &n, &m, &k);
    long all = 0;
    for(int i = 1; i <= n; i++) {
        all += mpow[i];
        scanf(" %s", S[i] + 1);
        for(int j = 1; j <= m; j++)
            hsh[j][f(S[i][j])] += mpow[i];
    }
    for(int i = 1; i <= n; i++) {
        long sum = 0;
        for(int j = 1; j <= m; j++) sum += all - hsh[j][f(S[i][j])];
        if(all * k == sum + k * mpow[i])
            return !printf("%d\n", i);
    }

    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

genetics.cpp: In function 'int main()':
genetics.cpp:25:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d", &n, &m, &k);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
genetics.cpp:29:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf(" %s", S[i] + 1);
         ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...