| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 153705 | kimcoding | Sajam (COCI18_sajam) | C++17 | 71 ms | 2424 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <cstdio>
#include <algorithm>
using namespace std;
bool chk[2][1005], map[1005][1005];
int cnt[2][1005], n, k, sum;
bool solve(int t) {
if (sum <= k) return true;
for (t = 1; t <= n * 2; t++) {
int Max = -1, a, b;
for (int i = 1; i <= n; i++) {
for (int j = 0; j <= 1; j++) {
if (chk[j][i]) continue;
if (Max < cnt[j][i])
Max = cnt[j][i], a = j, b = i;
}
}
chk[a][b] = true;
sum += n - 2 * cnt[a][b];
cnt[a][b] = n - cnt[a][b];
for (int i = 1; i <= n; i++)
cnt[!a][i] += ((map[a ? b : i][a ? i : b] ^= 1) ? 1 : -1);
if (sum <= k) return true;
}
return false;
}
int main() {
scanf("%d %d", &n, &k);
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
char x;
scanf(" %c", &x);
map[i][j] = (x == 'o');
cnt[0][j] += map[i][j];
cnt[1][i] += map[i][j];
}
sum += cnt[1][i];
}
printf("%s\n", solve(0) ? "DA" : "NE");
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... | ||||
