제출 #1184229

#제출 시각아이디문제언어결과실행 시간메모리
1184229lopkusGenetics (BOI18_genetics)C++20
27 / 100
2096 ms17168 KiB
#include <bits/stdc++.h> using i64 = long long; using u64 = unsigned long long; using u32 = unsigned; using u128 = unsigned __int128; const int M = 4100; std::bitset<M> B[M][4]; void solve() { int n, m, k; std::cin >> n >> m >> k; std::vector<std::vector<int>> a(n, std::vector<int>(m)); for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { char x; std::cin >> x; if(x == 'A') { a[i][j] = 0; } if(x == 'C') { a[i][j] = 1; } if(x == 'G') { a[i][j] = 2; } if(x == 'T') { a[i][j] = 3; } } } /** for(int i = 1; i <= n; i++) { int is = 1; for(int ath = 1; ath <= n; ath++) { if(i == ath) { continue; } int diff = 0; for(int x = 1; x <= m; x++) { diff += (a[i][x] != a[ath][x]); } is &= (diff == k); } if(is) { std::cout << i; return; } }**/ for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { B[i][a[i][j]].set(j); } } std::vector<std::vector<int>> cnt(n + 1, std::vector<int>(4)); for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { cnt[i][a[i][j]] += 1; } } std::function<int(int, int)> can = [&] (int i, int j) { int diff = 0; for(int x = 0; x < 4; x++) { diff += cnt[i][x] - (B[i][x] & B[j][x]).count(); } return diff == k; }; std::function<int(int)> is = [&] (int i) { int ok = 1; for(int y = 0; y < n; y++) { if(y == i) { continue; } ok &= can(i, y); } return ok; }; std::vector<int> p; for(int i = 1; i < n; i++) { if(can(0, i)) { p.push_back(i); } } random_shuffle(p.begin(), p.end()); if(p.size() == n - 1) { std::cout << 1; return; } for(auto may : p) { if(is(may)) { std::cout << may + 1; return; } } } int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int t = 1; //std::cin >> t; while (t--) { solve(); } 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...