Submission #984482

#TimeUsernameProblemLanguageResultExecution timeMemory
984482Ahmed57Genetics (BOI18_genetics)C++17
46 / 100
2053 ms35592 KiB
#include <bits/stdc++.h>

using namespace std;
#define int long long
const int T = 60;
int nah[T][4101][4];
int sz[T];
bitset<4101>xd[T];
mt19937 rng;
signed main(){
    rng.seed(time(0));
    int n,m,k;
    cin>>n>>m>>k;
    vector<string> v(n);
    for(int i = 0;i<n;i++)cin>>v[i];
    for(int it = 0;it<T;it++){
        for(int j = 0;j<n;j++){
            if(rng()%2){
                xd[it][j] = 1;
                sz[it]++;
                for(int e = 0;e<m;e++){
                    if(v[j][e]=='A')nah[it][e][0]++;
                    else if(v[j][e]=='C')nah[it][e][1]++;
                    else if(v[j][e]=='G')nah[it][e][2]++;
                    else nah[it][e][3]++;
                }
            }
        }
    }
    for(int i = 0;i<n;i++){
        bool bad = 0;
        for(int it = 0;it<T;it++){
            int lol = k*sz[it];
            if(xd[it][i]){
                lol-=k;
            }
            for(int e = 0;e<m;e++){
                if(v[i][e]=='A')lol-=nah[it][e][1]+nah[it][e][2]+nah[it][e][3];
                if(v[i][e]=='C')lol-=nah[it][e][0]+nah[it][e][2]+nah[it][e][3];
                if(v[i][e]=='G')lol-=nah[it][e][0]+nah[it][e][1]+nah[it][e][3];
                if(v[i][e]=='T')lol-=nah[it][e][0]+nah[it][e][1]+nah[it][e][2];
            }
            if(lol!=0){
                bad = 1;
                break;
            }
        }
        if(bad==0){
            cout<<i+1<<endl;
            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...