Submission #1274700

#TimeUsernameProblemLanguageResultExecution timeMemory
1274700Davdav1232Genetics (BOI18_genetics)C++20
100 / 100
748 ms20080 KiB
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<vector<int>> vii;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m, k; cin>>n>>m>>k;
    vector<pair<string, int>> villains(n);
    for(int i=0; i<n; i++){
        cin>>villains[i].first;
        villains[i].second=i+1;
    }
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            if(villains[i].first[j]=='A') villains[i].first[j]-='A';
            if(villains[i].first[j]=='C') villains[i].first[j]-='C'-1;
            if(villains[i].first[j]=='G') villains[i].first[j]-='G'-2;
            if(villains[i].first[j]=='T') villains[i].first[j]-='T'-3;
        }
    }
    vector<bool> is_real(n, 1);
    int rounds=30;
    random_device g;
    while(rounds--){
        vector<vector<int>> count(m, vector<int> (4, 0));
        shuffle(villains.begin(), villains.end(), g);
        for(int i=0; i<n; i++){
            int curr=i*k;
            for(int j=0; j<m; j++){
                curr-=i-count[j][villains[i].first[j]];
                count[j][villains[i].first[j]]++;
            }
            if(curr!=0){
                is_real[villains[i].second-1]=0;
            }
        }
    }
    for(int i=0; i<n; i++){
        if(is_real[i]){
            cout<<i+1;
            return 0;
        }
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...