Submission #104642

#TimeUsernameProblemLanguageResultExecution timeMemory
104642groeneprofGenetics (BOI18_genetics)C++14
100 / 100
1068 ms135160 KiB
#include <bits/stdc++.h> #define int long long #define P(x) do {if(debug) cout << x << endl;} while(false) #define H(x) P(#x << ": " << x) #define FR(i, a, b) for(int i = (a); i < (b); ++i) #define F(i, n) FR(i, 0, n) #define DR(i, a, b) for(int i = (b); i --> (a);) #define D(i, n) DR(i, 0, n) #define S(s) (int)(s).size() #define ALL(x) (x).begin(), (x).end() #define MI(x, a) (x) = min(x, a) #define MA(x, a) (x) = max(x, a) #define V vector #define pb push_back #define mp make_pair using namespace std; const bool debug = 0; const int tries = 3; const int mod = 1e9+7; int N,M,K; vector<vector<int> > people, key; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); random_device rd; mt19937 gen(rd()); uniform_int_distribution<> dis(0, mod-1); map<char,int> mp; mp['A'] = 0; mp['C'] = 1; mp['G'] = 2; mp['T'] = 3; cin>>N>>M>>K; people.resize(N, vector<int> (M, 0)); key.resize(4, vector<int> (M, 0)); F(i, N){ F(j, M){ char c; cin>>c; people[i][j] = mp[c]; } } int pos = N; vector<bool> vv(N, true); while(pos>1){ vector<int> weight(N); int sw = 0; F(i, N){ sw += weight[i] = dis(gen); sw %= mod; } //weight = {1, 10, 100, 1000}; // = 1111; key.assign(4, vector<int> (M, 0)); F(i, N){ F(j, M){ key[people[i][j]][j] += weight[i]; key[people[i][j]][j] %= mod; } } F(i, N) if(vv[i]){ int sum = 0; F(j, M){ F(k, 4) if(k != people[i][j]){ sum += key[k][j]; sum%=mod; } } if(sum != ((sw-weight[i]+mod)*K)%mod && vv[i]){ P(sum<<" "<<((sw-weight[i]+mod)*(K))%mod); P("not "<<i+1); pos--; vv[i] = false; } } } F(i, N){ if(vv[i]){ cout<<i+1<<endl; } } P("nice"); 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...