# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
263500 | kingfran1907 | Sajam (COCI18_sajam) | C++14 | 2300 ms | 2552 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define X first
#define Y second
using namespace std;
typedef long long llint;
const int maxn = 1010;
const int base = 31337;
const int mod = 1e9+7;
const int inf = 0x3f3f3f3f;
const int logo = 20;
const int off = 1 << logo;
const int treesiz = off << 1;
int n, k;
char niz[maxn][maxn];
bitset< maxn > b[maxn];
int pr[maxn];
bool flag[maxn];
int main() {
srand(time(0));
scanf("%d%d", &n, &k);
for (int i = 0; i < n; i++) {
scanf("%s", niz+i);
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (niz[i][j] == 'o') b[i][j] = 1;
else b[i][j] = 0;
}
}
if (k == 0) {
memset(flag, false, sizeof flag);
for (int i = 0; i < n; i++) {
if (niz[0][i] == 'o') flag[i] = true;
}
bool ac = true;
for (int i = 0; i < n; i++) {
int cnt = 0;
for (int j = 0; j < n; j++) {
cnt += ((niz[i][j] == 'o') + flag[j]) % 2;
}
if (cnt > 0 && cnt < n) ac = false;
}
if (ac) printf("DA\n");
else printf("NE\n");
return 0;
}
for (int i = 0; i < n; i++) pr[i] = i;
random_shuffle(pr, pr+n);
for (int ab = 0; ab < min(30, n); ab++) {
int tren = pr[ab];
for (int i = 0; i < n; i++) {
if (niz[tren][i] == 'o') flag[i] = true;
else flag[i] = false;
}
int ac = 0;
for (int i = 0; i < n; i++) {
int x = 0;
for (int j = 0; j < n; j++) {
x += ((niz[i][j] == 'o') + flag[j]) % 2;
}
ac += min(x, n - x);
}
if (ac <= k) {
printf("DA\n");
return 0;
}
for (int a = 0; a < n; a++) {
b[tren][a] = 1 - b[tren][a];
int ac = 0;
for (int i = 0; i < n; i++) {
int x = (b[tren] ^ b[i]).count();
ac += min(x, n - x);
}
if (ac <= k - 1) {
printf("DA\n");
return 0;
}
b[tren][a] = 1 - b[tren][a];
}
}
printf("NE\n");
return 0;
}
컴파일 시 표준 에러 (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... |