#include <bits/stdc++.h>
using namespace std;
auto solve(int x, int y) {
char ch, replacech;
if (x >= y) {
ch = '+';
replacech = '-';
} else {
ch = '-';
replacech = '+';
}
vector <vector <char>> a(x, vector <char>(y, ch));
int ans;
if (x >= y) {
ans = x;
for (int j = 0; j < (y - 1) / 2; j++) {
for (int i = 0; i < x / 2 + 1; i++)
a[i][j] = replacech;
ans++;
}
} else {
ans = y;
for (int i = 0; i < (x - 1) / 2; i++) {
for (int j = 0; j < y / 2 + 1; j++)
a[i][j] = replacech;
ans++;
}
}
cout << ans << '\n';
return a;
}
int main() {
int t;
cin >> t;
while (t--) {
int x, y;
cin >> x >> y;
auto a = solve(x, y);
for (int i = 0; i < x; i++, cout << '\n')
for (int j = 0; j < y; j++)
cout << a[i][j];
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
2 ms |
340 KB |
Output is correct |
4 |
Incorrect |
3 ms |
340 KB |
Wrong answer in test 5 29: 31 < 32 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
32 ms |
1240 KB |
Wrong answer in test 97 21: 107 < 116 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
36 ms |
1228 KB |
Wrong answer in test 24 24: 35 < 44 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
2 ms |
340 KB |
Output is correct |
4 |
Incorrect |
3 ms |
340 KB |
Wrong answer in test 5 29: 31 < 32 |
5 |
Halted |
0 ms |
0 KB |
- |