이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1005;
typedef pair <int, int> pi;
int t, n, m, a, b;
char c[MAXN][MAXN];
bool moze (int x, int y) {
if (x == 0 || y == 0) return 1;
int ost = x * y - max(a - (m - y), 0) * x;
return ost / y + n - x >= b;
}
void build (int x, int y) {
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (i >= x) c[i][j] = '-';
if (j >= y) c[i][j] = '+';
}
}
if (y == 0) return;
int br = max(a - (m - y), 0), curr = 0;
for (int i = 0; i < x; i++) {
for (int j = 0; j < y; j++) {
c[i][(curr + j) % y] = j < br ? '+' : '-';
}
curr = (curr + br) % y;
}
}
int main () {
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> t;
while (t--) {
cin >> n >> m;
a = m / 2 + 1;
b = n / 2 + 1;
int sol = 0;
pi best = {0, 0};
for (int x = 0; x <= n; x++) {
for (int y = 0; y <= m; y++) {
if (x + y > sol && moze(x, y)) {
sol = x + y;
best = {x, y};
}
}
}
build(best.first, best.second);
cout << sol << '\n';
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cout << c[i][j];
}
cout << '\n';
}
}
return 0;
}
# | 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... |