Submission #651350

#TimeUsernameProblemLanguageResultExecution timeMemory
651350fatemetmhrGenetics (BOI18_genetics)C++17
100 / 100
970 ms36296 KiB
// ~ Be Name Khoda ~ // Harf ke nazanim... // Zende bemoonim? // Ya oonm na? #include<bits/stdc++.h> using namespace std; typedef long long ll; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); #define pb push_back #define mp make_pair #define all(x) x.begin(), x.end() #define fi first #define se second const int maxn = 1e6 + 10; const int maxn5 = 5e5 + 10; const int maxnt = 1.2e6 + 10; const int maxn3 = 4102; const int mod = 1e9 + 7; const ll inf = 1e18; string s[maxn3]; ll sum[maxn3], w[maxn3], ans[maxn3]; int n, m, k; inline void solve(char a, char b){ for(int i = 0; i < m; i++) sum[i] = 0; for(int i = 0; i < n; i++) for(int j = 0; j < m; j++){ if(s[i][j] == a) sum[j] += w[i]; if(s[i][j] == b) sum[j] -= w[i]; } for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) ans[i] += (sum[j] - w[i] * (s[i][j] == a ? 1 : (s[i][j] == b ? -1 : 0))) * (s[i][j] == a ? 1 : (s[i][j] == b ? -1 : 0)); return; } int main() { ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); cin >> n >> m >> k; ll sumw = 0; for(int i = 0; i < n; i++){ cin >> s[i]; w[i] = rng() % mod + 1; sumw += w[i]; } solve('A', 'C'); solve('A', 'T'); solve('A', 'G'); solve('C', 'T'); solve('C', 'G'); solve('T', 'G'); for(int i = 0; i < n; i++) if(ans[i] == (sumw - w[i]) * (3 * m - 4 * k)) return cout << i + 1 << endl, 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...