이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e9;
const int N = 1e5 + 2;
int t, n, m;
char a[1002][1002];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int t;
cin >> t;
while (t--) {
cin >> n >> m;
int ans = 0, lin = 0, col = 0;
for (int i = 0; i <= n; i++)
for (int j =0; j <= m; j++) {
if (m / 2 + 1 <= m - j || n / 2 + 1 <= n - i) {
if (ans < i + j) {
ans = i + j;
lin = i;
col = j;
}
}
else {
int l = m / 2 + 1 - (m - j);
int c = n / 2 + 1 - (n - i);
int nr = (j + l * i - 1) / j;
if (c <= i - nr && ans < i + j) {
ans = i + j;
lin = i;
col = j;
}
}
}
cout << ans << "\n";
for (int i = 0; i < lin; i++)
for (int j = m - 1; j >= col; j--)
a[i][j] = '+';
for (int j = 0; j < col; j++)
for (int i = n - 1; i >= 0; i--)
a[i][j] = '-';
if (m / 2 + 1 > m - col) {
int c = m / 2 + 1 - (m - col);
int k = 0;
for (int i = 0; i < lin; i++) {
for (int j = 0; j < c; j++) {
a[i][k] = '+';
k = (k + 1) % col;
}
}
}
for (int i = lin; i < n; i++)
for (int j = col; j < m; j++)
a[i][j] = '-';
for (int i = 0; i < n; i++, cout << "\n")
for (int j = 0; j < m; j++)
cout << a[i][j];
}
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... |