Submission #96037

#TimeUsernameProblemLanguageResultExecution timeMemory
96037caesar2001Genetics (BOI18_genetics)C++14
46 / 100
2033 ms796804 KiB
#include <bits/stdc++.h> #define ll long long #define lsb(x) (x & -x) using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); //freopen("a.in", "r", stdin); //freopen("a.out", "w", stdout); int n, m, k; cin >> n >> m >> k; k = m - k; vector<int> code(30, 0); code['A' - 'A'] = 1; code['C' - 'A'] = 2; code['G' - 'A'] = 3; code['T' - 'A'] = 4; vector<vector<vector<ll>>> v(5, vector<vector<ll>> (n + 1, vector<ll> (m + 1, 0))); for(int i = 1; i <= n; i ++) { string s; cin >> s; for(int j = 0; j < m; j ++) v[code[s[j] - 'A']][i][j + 1] = 1; } srand(time(NULL)); vector<ll> hs(n + 1, 0); for(int i = 1; i <= n; i ++) hs[i] = rand(); vector<ll> ans(n + 1, 0); vector<ll> ths(m + 1, 0); for(int color = 1; color <= 4; color ++) { for(int i = 1; i <= m; i ++) ths[i] = 0; for(int i = 1; i <= m; i ++) for(int k = 1; k <= n; k ++) ths[i] += (v[color][k][i] * hs[k]); for(int i = 1; i <= n; i ++) for(int k = 1; k <= m; k ++) ans[i] += (v[color][i][k] * ths[k]); } vector<ll> solhs(n + 1, 0); for(int i = 1; i <= n; i ++) { for(int j = 1; j <= n; j ++) { if(i == j) solhs[i] += (m * hs[j]); else solhs[i] += (k * hs[j]); } } for(int i = 1; i <= n; i ++) { if(solhs[i] == ans[i]) { cout << i; return 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...