Submission #866402

#TimeUsernameProblemLanguageResultExecution timeMemory
866402The_SamuraiGenetics (BOI18_genetics)C++17
100 / 100
1621 ms102848 KiB
#pragma GCC optimize("O3", "unroll-loops") #pragma GCC target("avx2", "popcnt") #include "bits/stdc++.h" using namespace std; using ll = long long; const ll inf = 1e18; const int M = 4100; random_device rd; int main() { srand(time(0)); cin.tie(0)->sync_with_stdio(false); #ifdef sunnatov freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int n, m, k; cin >> n >> m >> k; vector<string> a(n); for (string &s: a) cin >> s; vector<bitset<M * 4>> bs(n); for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) { if (a[i][j] == 'A') bs[i].set(4 * j); if (a[i][j] == 'C') bs[i].set(4 * j + 1); if (a[i][j] == 'G') bs[i].set(4 * j + 2); if (a[i][j] == 'T') bs[i].set(4 * j + 3); } vector ok(n, vector(n, -1)); vector<int> pos(n); iota(pos.begin(), pos.end(), 0); shuffle(pos.begin(), pos.end(), rd); for (int i = 0; i < min(10, n); i++) { for (int j = 0; j < n; j++) { if (pos[i] == j) continue; if ((bs[pos[i]] ^ bs[j]).count() != 2 * k) { ok[pos[i]][j] = ok[j][pos[i]] = 0; } } } for (int i = 0; i < n; i++) { if (count(ok[i].begin(), ok[i].end(), 0)) continue; for (int j = 0; j < n; j++) { if (i == j or ok[i][j] == 1) continue; if ((bs[i] ^ bs[j]).count() != 2 * k) { ok[i][j] = ok[j][i] = 0; break; } else { ok[i][j] = ok[j][i] = 1; } } if (!count(ok[i].begin(), ok[i].end(), 0)) { cout << i + 1; return 0; } } }

Compilation message (stderr)

genetics.cpp: In function 'int main()':
genetics.cpp:37:46: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   37 |             if ((bs[pos[i]] ^ bs[j]).count() != 2 * k) {
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
genetics.cpp:46:41: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   46 |             if ((bs[i] ^ bs[j]).count() != 2 * 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...