제출 #95835

#제출 시각아이디문제언어결과실행 시간메모리
95835andrei110901Genetics (BOI18_genetics)C++14
46 / 100
1729 ms148860 KiB
#include <bits/stdc++.h>

using namespace std;

int func(char ch){
    if(ch == 'A')
        return 0;
    if(ch == 'C')
        return 1;
    if(ch == 'G')
        return 2;
    return 3;
}

vector <int> v;
int mat[4][4100][4100];
long long aux[4][4100], rez[4100];

inline bool ok(int i, int m, int k, int n){
    long long loc = 0;
    for(int j = 0; j < n; j++){
        if(j != i)
            loc += 1LL * (m - k) * v[j];
        else
            loc += 1LL * m * v[j];
    }
    return loc == rez[i];
}

int main()
{
    int n, m, k;
    char ch;
    cin >> n >> m >> k;
    srand(time(NULL));
    v.resize(n);
    for(auto &e : v)
        e = rand();
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin >> ch;
            ch = func(ch);
            mat[ch][i][j] = 1;
        }
    }
    for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++)
            for(int cul = 0; cul < 4; cul++)
                aux[cul][j] += 1LL * mat[cul][i][j] * v[i];
    for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++)
            for(int cul = 0; cul < 4; cul++)
                rez[i] += 1LL * mat[cul][i][j] * aux[cul][j];
    int i = 0;
    while(i < n && !ok(i, m, k, n)){
        i++;
    }
    cout << i + 1;
    return 0;
}

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

genetics.cpp: In function 'int main()':
genetics.cpp:43:19: warning: array subscript has type 'char' [-Wchar-subscripts]
             mat[ch][i][j] = 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...