# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
395746 | ly20 | Red-blue table (IZhO19_stones) | C++17 | 65 ms | 1844 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1123;
int tb[MAXN][MAXN];
int sl[MAXN], sc[MAXN];
int n, m;
bool teste(int a, int b) {
if(a > n || b > m) return false;
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= m; j++) {
tb[i][j] = 0;
sl[i] = m;
sc[j] = 0;
}
}
bool ok = true;
for(int i = n; i > n - a; i--) {
for(int j = 1; j <= m; j++) {
tb[i][j] = 1;
sl[i]--;
sc[j]++;
}
}
for(int j = m; j > m - b; j--) {
for(int i = n; i >= 1; i--) {
tb[i][j] = 0;
sl[i]++;
sc[j]--;
}
}
int l = n - a, c = m - b;
int liml = m / 2 + 1, limc = n / 2 + 1;
if(l == 0 || c == 0) return true;
for(int i = 1; i <= l; i++) {
int qtdisp = sl[i] - liml;
for(int j = 1; j <= c; j++) {
if(qtdisp > 0 && sc[j] < limc) {
qtdisp--;
sc[j]++;
tb[i][j] = 1;
sl[i]--;
}
}
}
for(int i = 1; i <= c; i++) if(sc[i] < limc) ok = false;
return ok;
}
int main() {
int t;
scanf("%d", &t);
while(t--) {
scanf("%d %d", &n, &m);
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= m; j++) {
tb[i][j] = 0;
sl[i] = m;
sc[j] = 0;
}
}
if(n == 1) {
printf("%d\n", m);
for(int i = 0; i < m; i++) printf("-");
printf("\n");
continue;
}
else if(m == 1) {
printf("%d\n", n);
for(int i = 0; i < n; i++) printf("+\n");
continue;
}
bool ok = false;
int resp = 0;
for(int i = 1; i < 5; i++) {
for(int j = 0; j <= i; j++) {
if(ok) continue;
ok = teste(j, i - j);
if(ok) resp = i;
}
}
printf("%d\n", m + n - resp);
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= m; j++) {
if(tb[i][j] == 0) printf("+");
else printf("-");
}
printf("\n");
}
}
}
컴파일 시 표준 에러 (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... |