Submission #866390

#TimeUsernameProblemLanguageResultExecution timeMemory
866390The_SamuraiGenetics (BOI18_genetics)C++17
46 / 100
2047 ms21452 KiB
//#pragma GCC optimize("O3") //#pragma GCC target("avx2") #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; bool sub2 = true; for (int i = 0; i < n and sub2; i++) for (char x: a[i]) sub2 &= x == 'A' or x == 'C'; if (sub2) { vector<bitset<M>> bs(n); for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) if (a[i][j] == 'A') bs[i].set(j); vector<bool> ok(n, true); 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() != k) { ok[pos[i]] = ok[j] = false; } } } for (int i = 0; i < n; i++) { if (!ok[i]) continue; for (int j = 0; j < n; j++) { if (i == j) continue; if ((bs[i] ^ bs[j]).count() != k) { ok[i] = ok[j] = false; break; } } if (ok[i]) { cout << i + 1; return 0; } } } for (int i = 0; i < n; i++) { bool ok = true; for (int j = 0; j < n and ok; j++) { if (i == j) continue; int cnt = 0; for (int p = 0; p < m and cnt <= k; p++) cnt += a[i][p] != a[j][p]; ok &= cnt == k; } if (ok) { cout << i + 1; return 0; } } }

Compilation message (stderr)

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