Submission #488106

#TimeUsernameProblemLanguageResultExecution timeMemory
488106MohamedAhmed04Genetics (BOI18_genetics)C++14
100 / 100
611 ms36296 KiB
#include <bits/stdc++.h> using namespace std ; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()) ; int rand(int l , int r) { return uniform_int_distribution<int>(l , r)(rng) ; } const int MAX = 4100 + 10 ; string arr[MAX] ; int n , m , k ; long long freq[MAX][4] ; long long val[MAX] ; int f(char c) { if(c == 'A') return 0 ; else if(c == 'C') return 1 ; else if(c == 'G') return 2 ; else return 3 ; } int main() { ios_base::sync_with_stdio(0) ; cin.tie(0) ; cin>>n>>m>>k ; for(int i = 0 ; i < n ; ++i) cin>>arr[i] ; long long sum = 0 ; for(int i = 0 ; i < n ; ++i) { val[i] = rand(1 , 1e9) ; sum += 1ll * val[i] * k ; } for(int j = 0 ; j < m ; ++j) { for(int i = 0 ; i < n ; ++i) freq[j][f(arr[i][j])] += val[i] ; } for(int i = 0 ; i < n ; ++i) { long long cnt = 0 ; for(int j = 0 ; j < m ; ++j) { for(int c = 0 ; c < 4 ; ++c) { if(c != f(arr[i][j])) cnt += freq[j][c] ; } } if(cnt == sum - val[i] * k) return cout<<i+1<<"\n" , 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...