Submission #416794

#TimeUsernameProblemLanguageResultExecution timeMemory
416794SirCovidThe19thGenetics (BOI18_genetics)C++14
46 / 100
468 ms41828 KiB
#include <bits/stdc++.h>
using namespace std;

int n, m, k, idx[100]; string s[4005]; long long r[4005], hsh[4005][4], tot;

int main() {
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    cin >> n >> m >> k; 
    idx['A'] = 0; idx['G'] = 1; idx['C'] = 2; idx['T'] = 3;
    for (int i = 0; i < n; i++){
        cin >> s[i]; 
        r[i] = uniform_int_distribution<long long>(1e3, 1e10)(rng); tot += r[i];
        for (int j = 0; j < m; j++) hsh[j][idx[s[i][j]]] += r[i];
    }
    for (int i = 0; i < n; i++){
        long long val = 0;
        for (int j = 0; j < m; j++) val += tot-hsh[j][idx[s[i][j]]];
        if (val == k*(tot-r[i])){ cout<<i+1; break; }
    }
}



Compilation message (stderr)

genetics.cpp: In function 'int main()':
genetics.cpp:13:55: warning: array subscript has type 'char' [-Wchar-subscripts]
   13 |         for (int j = 0; j < m; j++) hsh[j][idx[s[i][j]]] += r[i];
      |                                                       ^
genetics.cpp:17:66: warning: array subscript has type 'char' [-Wchar-subscripts]
   17 |         for (int j = 0; j < m; j++) val += tot-hsh[j][idx[s[i][j]]];
      |                                                                  ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...