Submission #878235

#TimeUsernameProblemLanguageResultExecution timeMemory
878235vjudge1Genetics (BOI18_genetics)C++17
0 / 100
34 ms15028 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back mt19937 ran(chrono::steady_clock::now().time_since_epoch().count()); 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) { int sum = 0; for (int j = 0; j < n; ++j) { for (int l = 0; l < 4; ++l) { sum += abs(cnt[i][l] - cnt[j][l]); } } if (sum >= k * (n - 1)) { check.pb(i); } } shuffle(idx, idx + n, ran); k = m - k; 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; } } if (isAns == true) { cout << i + 1; return 0; } } return 0; }

Compilation message (stderr)

genetics.cpp: In function 'int main()':
genetics.cpp:65:45: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   65 |             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...