이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
}
}
컴파일 시 표준 에러 (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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |