#include <bits/stdc++.h>
using namespace std;
#ifdef MIKU
string dbmc = "\033[1;38;2;57;197;187m", dbrs = "\033[0m";
#define debug(x...) cout << dbmc << "[" << #x << "]: ", dout(x)
void dout() { cout << dbrs << endl; }
template <typename T, typename ...U>
void dout(T t, U ...u) { cout << t << (sizeof...(u) ? ", " : ""); dout(u...); }
#else
#define debug(...) 39
#endif
#define fs first
#define sc second
#define mp make_pair
#define FOR(i, j, k) for (int i = j, Z = k; i < Z; i++)
using ll = long long;
typedef pair<int, int> pii;
const int MXN = 1005;
int n, m;
char c[MXN][MXN], d[MXN][MXN];
int ch(int n, int m, char c[][MXN]) {
FOR(i, 0, n) FOR(j, 0, m) c[i][j] = '+';
int y = n / 2 + 1;
int x = (m - 1) / 2 * n / y;
int t = 0;
FOR(j, 0, x) {
FOR(i, 0, y) {
c[t][j] = '-';
if (++t == n) t = 0;
}
}
return n + x;
}
void miku() {
cin >> n >> m;
int a = ch(n, m, c);
int b = ch(m, n, d);
if (a < b) {
FOR(i, 0, n) FOR(j, 0, m) c[i][j] = ('+' ^ '-' ^ d[j][i]);
}
cout << max(a, b) << '\n';
FOR(i, 0, n) {
FOR(j, 0, m) cout << c[i][j];
cout << '\n';
}
}
int32_t main() {
cin.tie(0) -> sync_with_stdio(false);
cin.exceptions(cin.failbit);
int t;
cin >> t;
while (t--) miku();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
464 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
464 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
2 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
1616 KB |
Output is correct |
2 |
Correct |
20 ms |
2900 KB |
Output is correct |
3 |
Correct |
17 ms |
2904 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
1748 KB |
Output is correct |
2 |
Correct |
15 ms |
2652 KB |
Output is correct |
3 |
Correct |
15 ms |
2108 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
464 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
2 ms |
604 KB |
Output is correct |
5 |
Correct |
23 ms |
1616 KB |
Output is correct |
6 |
Correct |
20 ms |
2900 KB |
Output is correct |
7 |
Correct |
17 ms |
2904 KB |
Output is correct |
8 |
Correct |
18 ms |
1748 KB |
Output is correct |
9 |
Correct |
15 ms |
2652 KB |
Output is correct |
10 |
Correct |
15 ms |
2108 KB |
Output is correct |
11 |
Correct |
8 ms |
676 KB |
Output is correct |
12 |
Correct |
15 ms |
2396 KB |
Output is correct |
13 |
Correct |
15 ms |
2652 KB |
Output is correct |
14 |
Correct |
12 ms |
2396 KB |
Output is correct |
15 |
Correct |
18 ms |
3420 KB |
Output is correct |
16 |
Correct |
20 ms |
2764 KB |
Output is correct |
17 |
Correct |
10 ms |
1884 KB |
Output is correct |