Submission #441797

#TimeUsernameProblemLanguageResultExecution timeMemory
441797Haruto810198Genetics (BOI18_genetics)C++17
100 / 100
546 ms174856 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define double long double #define FOR(i, l, r, d) for(int i=(l); i<=(r); i+=(d)) #define szof(x) ((int)(x).size()) #define vi vector<int> #define pii pair<int,int> #define F first #define S second #define pb push_back #define eb emplace_back #define mkp make_pair const int INF = 2147483647; const int LNF = INF*INF; const int MOD = 1000000007; const int mod = 998244353; //#pragma GCC optimize("Ofast") //#pragma GCC optimize("unroll-loops") const int MAX = 4110; int n, m, k; string str[MAX]; vi arr[MAX]; int w[MAX]; int csum[MAX][4]; int req; int res; void check(int id){ int sum = 0; req -= w[id] * k; FOR(j, 0, m-1, 1){ FOR(c, 0, 3, 1){ if(c == arr[id][j]) continue; sum += csum[j][c]; } } if(sum==req){ res = id; } //cerr<<sum<<" "<<req<<endl; req += w[id] * k; } signed main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); srand(time(NULL)); cin>>n>>m>>k; FOR(i, 1, n, 1){ cin>>str[i]; } FOR(i, 1, n, 1){ FOR(j, 0, m-1, 1){ if(str[i][j]=='A'){ arr[i].pb(0); } else if(str[i][j]=='C'){ arr[i].pb(1); } else if(str[i][j]=='G'){ arr[i].pb(2); } else if(str[i][j]=='T'){ arr[i].pb(3); } } } FOR(i, 1, n, 1){ w[i] = rand(); req += w[i]; } req *= k; FOR(i, 1, n, 1){ FOR(j, 0, m-1, 1){ csum[j][arr[i][j]] += w[i]; } } FOR(i, 1, n, 1){ check(i); } cout<<res<<'\n'; 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...