# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
92093 | Kastanda | Sajam (COCI18_sajam) | C++11 | 492 ms | 632 KiB |
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;
const int N = 1003;
int n, k;
char S[N];
bitset < N > A[N], B[N];
int main()
{
scanf("%d%d", &n, &k);
for (int i = 0; i < n; i++)
{
scanf("%s", &S);
for (int j = 0; j < n; j++)
A[i][j] = (S[j] == 'o'), B[i][j] = !A[i][j];
memset(S, 0, sizeof(S));
}
for (int i = 0; i < n; i++)
{
int cnt = 0;
for (int j = 0; j < n; j++)
{
int a = (A[i] ^ A[j]).count();
int b = (B[i] ^ A[j]).count();
int c = (A[i] ^ B[j]).count();
int d = (B[i] ^ B[j]).count();
cnt += min({a, b, c, d});
}
if (cnt <= k)
return !printf("DA\n");
}
if (k == n)
{
for (int i = 0; i < n; i++)
{
A[0][i] = !A[0][i];
B[0][i] = !B[0][i];
int cnt = 0;
for (int j = 0; j < n; j++)
{
int a = (A[0] ^ A[j]).count();
int b = (B[0] ^ A[j]).count();
int c = (A[0] ^ B[j]).count();
int d = (B[0] ^ B[j]).count();
cnt += min({a, b, c, d});
}
if (cnt <= k)
return !printf("DA\n");
A[0][i] = !A[0][i];
B[0][i] = !B[0][i];
}
}
return !printf("NE\n");
}
Compilation message (stderr)
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |