제출 #96027

#제출 시각아이디문제언어결과실행 시간메모리
96027caesar2001Genetics (BOI18_genetics)C++14
27 / 100
302 ms89592 KiB
#include <bits/stdc++.h> #define ll long long #define lsb(x) (x & -x) using namespace std; inline void transpune(const vector<vector<int>> &v, vector<vector<int>> &ans, int n, int m) { for(int i = 1; i <= n; i ++) for(int j = 1; j <= m; j ++) ans[j][i] = v[i][j]; } inline void multiply(const vector<vector<int>> &a, const vector<int> &b, vector<int> &ans, int n, int m) { for(int i = 1; i <= n; i ++) ans[i] = 0; for(int i = 1; i <= n; i ++) for(int k = 1; k <= m; k ++) ans[i] += (a[i][k] * b[k]); } inline void add(vector<int> &ans, const vector<int> &a, int n) { for(int i = 1; i <= n; i ++) ans[i] += a[i]; } 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<int>>> v(5, vector<vector<int>> (n + 1, vector<int> (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<int> hs(n + 1, 0); for(int i = 1; i <= n; i ++) hs[i] = rand() % 2000; vector<int> ans(n + 1, 0); vector<vector<int>> t(m + 1, vector<int> (n + 1, 0)); vector<int> ths(m + 1, 0); vector<int> aux(n + 1, 0); for(int i = 1; i <= 4; i ++) { transpune(v[i], t, n, m); multiply(t, hs, ths, m, n); multiply(v[i], ths, aux, n, m); add(ans, aux, n); } vector<vector<int>> sol(n + 1, vector<int> (n + 1, k)); for(int i = 1; i <= n; i ++) sol[i][i] = m; vector<int> solhs(n + 1, 0); multiply(sol, hs, solhs, n, n); 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...