이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
const int N = 1e3 + 5;
priority_queue <pair <int, int>> q;
char jog[N][N];
int main() {
int t;
cin >> t;
while ( t-- ) {
int n, m;
cin >> n >> m;
bool tr = 0;
if (n < m) {
swap (n, m);
tr = 1;
}
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) {
jog[i][j] = '+';
}
}
int a = n / 2 + 1;
int b = (m - 1) / 2;
int ans = n + ((n * b) / a);
for (int i = 1; i <= n; ++i) {
if (b) q.push({b, i});
}
for (int i = 1; i <= b; ++i) {
for (int j = 1; j <= a; ++j) {
if (q.empty()) break;
pair <int, int> x = q.top();
q.pop();
jog[x.ss][i] = '-';
if (x.ff > 1) {
q.push ({x.ff - 1, x.ss});
}
}
if (q.empty()) break;
}
if (tr) {
cout << ans << endl;
for (int i = 1; i <= n; ++i) {
for (int j = m; j > 0; j--) {
if (jog[i][j] == '-') jog[i][j] = '+';
else jog[i][j] = '-';
}
}
int l1 = 1, r1 = m;
for (int i = 1; i <= m; ++i) {
for (int j = 1; j <= n; ++j) {
cout << jog[l1][r1];
l1++;
}
l1 = 1;
r1--;
cout << endl;
}
}
else {
cout << ans << endl;
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) {
cout << jog[i][j];
}
cout << endl;
}
}
}
}
# | 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... |