# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
344076 | Nurlykhan | Red-blue table (IZhO19_stones) | C++17 | 44 ms | 1392 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = 1024;
int t;
int n, m;
bool a[N][N], ans[N][N];
int cnt() {
int res = 0;
for (int i = 0; i < n; i++) {
int s = 0;
for (int j = 0; j < m; j++) {
if (a[i][j]) s++;
else s--;
}
if (s > 0) res++;
}
for (int j = 0; j < m; j++) {
int s = 0;
for (int i = 0; i < n; i++) {
if (a[i][j]) s++;
else s--;
}
if (s < 0) res++;
}
return res;
}
void solve() {
int mx = 0;
for (int mask = 0; mask < (1 << (n * m)); mask++) {
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if ((mask >> (i * m + j)) % 2) {
a[i][j] = 1;
} else {
a[i][j] = 0;
}
}
}
int cur = cnt();
if (cur > mx) {
mx = cur;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
ans[i][j] = a[i][j];
}
}
}
}
printf("%d\n", mx);
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (ans[i][j])
printf("+");
else
printf("-");
}
printf("\n");
}
}
void tupo() {
if (n <= m) {
bool boo = 1;
int ans = m + 1;
if (n <= 2) {
boo = 0;
ans = m;
}
printf("%d\n", ans);
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (boo && i == 0) printf("+");
else printf("-");
}
printf("\n");
}
} else {
bool boo = 1;
int ans = n + 1;
if (m <= 2) {
boo = 0;
ans = n;
}
printf("%d\n", ans);
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (boo && j == m - 1) printf("-");
else printf("+");
}
printf("\n");
}
}
}
int main() {
scanf("%d", &t);
while (t--) {
scanf("%d%d", &n, &m);
tupo();
}
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... |