Submission #878323

#TimeUsernameProblemLanguageResultExecution timeMemory
878323ArashJafariyanGenetics (BOI18_genetics)C++17
100 / 100
1985 ms41828 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back mt19937 ran(17); #pragma GCC optimize("Ofast,unroll-loops") #pragma GCC target("avx2") const int N = 4100; int n, m, k, idx[N], cnt[N][4]; char s[N][N]; bitset<N * 4> have[N]; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> m >> k; for (int i = 0; i < n; ++i) { idx[i] = i; cin >> s[i]; for (int j = 0; j < m; ++j) { char c = s[i][j]; if (c == 'A') { have[i][j] = true; ++cnt[i][0]; } else if (c == 'G') { have[i][j + m] = true; ++cnt[i][1]; } else if (c == 'C') { have[i][j + 2 * m] = true; ++cnt[i][2]; } else if (c == 'T') { have[i][j + 3 * m] = true; ++cnt[i][3]; } } } vector<int> check; for (int i = 0; i < n; ++i) { bool ok = true; for (int j = 0; j < n; ++j) { int sum = 0; for (int l = 0; l < 4; ++l) { sum += min(cnt[i][l], cnt[i][l]); } if (sum < m - k) { ok = false; } } check.pb(i); } k <<= 1; shuffle(idx, idx + n, ran); for (int _ : check) { int i = idx[_]; bool isAns = true; for (int j = 0; j < n; ++j) { if (i == j) { continue; } if ((have[i] ^ have[j]).count() != k) { isAns = false; break; } } if (isAns == true) { cout << i + 1; return 0; } } return 0; } /* */

Compilation message (stderr)

genetics.cpp: In function 'int main()':
genetics.cpp:47:14: warning: variable 'ok' set but not used [-Wunused-but-set-variable]
   47 |         bool ok = true;
      |              ^~
genetics.cpp:69:45: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   69 |             if ((have[i] ^ have[j]).count() != k) {
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...