제출 #163031

#제출 시각아이디문제언어결과실행 시간메모리
163031kuroniGenetics (BOI18_genetics)C++17
100 / 100
937 ms288096 KiB
#include <bits/stdc++.h> using namespace std; const int M = 4105, N = 4105; int m, n, x, sum[M][N][4]; char s[M][N]; vector<int> ve; random_device rd; mt19937_64 mt(rd()); int convert(char c) { switch (c) { case 'A': return 0; case 'T': return 1; case 'G': return 2; case 'C': return 3; default: return 0; } } bool check(int ind, int pos) { int cnt = (pos - (ind <= pos)) * x; for (int i = 1; i <= n; i++) { cnt -= sum[pos][i][convert(s[ind][i])]; } return cnt == 0; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> m >> n >> x; for (int i = 1; i <= m; i++) { cin >> (s[i] + 1); for (int j = 1; j <= n; j++) { int cur = convert(s[i][j]); for (int k = 0; k < 4; k++) { sum[i][j][k] = sum[i - 1][j][k] + (cur != k); } } ve.push_back(m + 1 - i); } shuffle(ve.begin() + 1, ve.end(), mt); for (int i = 1; i <= m; i++) { bool chk = true; for (int &v : ve) { if (!check(i, v)) { chk = false; break; } } if (chk) { return cout << i, 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...