#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
#define f1r(i, a, b) for (int i = a; i < b; i++)
#define f0r(i, a) f1r(i, 0, a)
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define sz(x) (int) (x).size()
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pi> vpi;
void print(vector<vi> a) {
f0r(i, sz(a)) {
f0r(j, sz(a[i])) {
cout << (a[i][j] ? '+' : '-');
}
cout << '\n';
}
}
void solve_case() {
int n, m; cin >> n >> m;
int x = ((n + 1) / 2 - 1) * 2;
int y = ((m + 1) / 2 - 1) * 2;
vector<vi> a(n, vi(m));
if (max(n, m) >= x + y) {
if (n > m) {
f0r(i, n) {
f0r(j, m) {
a[i][j] = 1;
}
}
cout << n << '\n';
print(a);
return;
} else {
cout << m << '\n';
print(a);
return;
}
}
f0r(i, x) {
f0r(j, y) {
a[i][j] = ((i+j)%2 ? 1 : 0);
}
}
f1r(i, x, n) {
f0r(j, y) {
a[i][j] = 1;
}
}
f1r(j, y, m) {
f0r(i, n) {
a[i][j] = 0;
}
}
cout << x + y << '\n';
print(a);
return;
}
int main() {
cin.tie(0)->sync_with_stdio(0);
int tt; cin >> tt;
while (tt--) {
solve_case();
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
in the table A+B is not equal to 4 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
364 KB |
in the table A+B is not equal to 46 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
in the table A+B is not equal to 4 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
45 ms |
1516 KB |
in the table A+B is not equal to 116 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
37 ms |
1572 KB |
in the table A+B is not equal to 44 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
in the table A+B is not equal to 4 |
2 |
Halted |
0 ms |
0 KB |
- |