이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
bitset<4101> dna[4101];
int diff[4101][4101];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n, m, k;
cin >> n >> m >> k;
vector<int> permN(n);
iota(permN.begin(), permN.end(), 0);
random_shuffle(permN.begin(), permN.end());
vector<int> permM(m);
iota(permM.begin(), permM.end(), 0);
random_shuffle(permM.begin(), permM.end());
for (int i = 0; i < n; i++) {
string ln; cin >> ln;
for (int j = 0; j < m; j++) {
if (ln[j] == 'A')
dna[permN[i]].set(permM[j]);
}
}
vector<int> cand;
cand.reserve(n);
for (int a = 1; a < n; a++) {
if ((dna[a] ^ dna[0]).count() == k) {
cand.push_back(a);
}
}
int ans = 0;
if (cand.size() < n - 1) {
for (int a : cand) {
bool ok = true;
for (int b = 1; b < n; b++) {
if (a != b && (dna[a] ^ dna[b]).count() != k) {
ok = false;
break;
}
}
if (ok) {
ans = a;
break;
}
}
}
cout << (find(permN.begin(), permN.end(), ans) - permN.begin() + 1) << "\n";
}
컴파일 시 표준 에러 (stderr) 메시지
genetics.cpp: In function 'int main()':
genetics.cpp:35:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if ((dna[a] ^ dna[0]).count() == k) {
~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
genetics.cpp:41:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (cand.size() < n - 1) {
~~~~~~~~~~~~^~~~~~~
genetics.cpp:45:45: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (a != b && (dna[a] ^ dna[b]).count() != 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... |