This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define X first
#define Y second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define test(args...) abc("[" + string(#args) + "]", args)
void abc() {cerr << endl;}
template <typename T, typename ...U> void abc(T a, U ...b) {
cerr << a << ' ', abc(b...);
}
template <typename T> void printv(T l, T r) {
while (l != r) cout << *l << " \n"[++l == r];
}
const int mod = 1e9 + 7, N = 200000;
bitset <4100> A[4100];
int main () {
ios::sync_with_stdio(false);
cin.tie(0);
int n, m, k;
cin >> n >> m >> k;
for (int i = 0; i < n; ++i) {
string s;
cin >> s;
for (int j = 0; j < m; ++j) {
if (s[j] == 'A') A[i][j].flip();
}
}
vector <bool> possible(n, false);
for (int i = 1; i < n; ++i) {
if ((A[i - 1] ^ A[i]).count() == k) possible[i] = true, possible[i - 1] = true;
}
for (int ans = 0; ans < n; ++ans) if (possible[ans]) {
bool is = true;
for (int i = 0; i < n; ++i) if (ans != i) {
is &= (A[i] ^ A[ans]).count() == k;
}
if (is) return cout << ans + 1 << endl, 0;
}
}
Compilation message (stderr)
genetics.cpp: In function 'int main()':
genetics.cpp:38:39: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
38 | if ((A[i - 1] ^ A[i]).count() == k) possible[i] = true, possible[i - 1] = true;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
genetics.cpp:43:43: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
43 | is &= (A[i] ^ A[ans]).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... |