#include <iostream>
int main() {
int nrt, sizx, sizy;
int sizx1, sizx2, sizy1, sizy2;
int ans;
int pos;
std::cin >> nrt;
while (nrt--) {
std::cin >> sizx >> sizy;
if (sizx <= sizy && sizx < 3) {
std::cout << sizy << '\n';
for (int index = 0; index < sizx; index++) {
for (int index2 = 0; index2 < sizy; index2++) {
std::cout << '-';
}
std::cout << '\n';
}
}
else if (sizy < 3) {
std::cout << sizx << '\n';
for (int index = 0; index < sizx; index++) {
for (int index2 = 0; index2 < sizy; index2++) {
std::cout << '+';
}
std::cout << '\n';
}
}
else {
sizx1 = (sizx - 1) >> 1;
sizx2 = (sizx >> 1) + 1;
sizy1 = (sizy - 1) >> 1;
sizy2 = (sizy >> 1) + 1;
ans = sizx + sizy + sizx1 + sizy1 - sizx2 - sizy2;
if (ans < sizy + (((sizx - 1) >> 1) * sizy) / ((sizy >> 1) + 1)) {
std::cout << sizy + (((sizx - 1) >> 1) * sizy) / ((sizy >> 1) + 1) << '\n';
pos = 0;
for (int index = 0; index < (((sizx - 1) >> 1) * sizy) / ((sizy >> 1) + 1); index++) {
if (pos + (sizy >> 1) + 1 > sizy) {
for (int index2 = 0; index2 < pos + (sizy >> 1) + 1 - sizy; index2++) {
std::cout << '+';
}
for (int index2 = pos + (sizy >> 1) + 1 - sizy; index2 < pos; index2++) {
std::cout << '-';
}
for (int index2 = pos; index2 < sizy; index2++) {
std::cout << '+';
}
pos += (sizy >> 1) + 1 - sizy;
}
else {
for (int index2 = 0; index2 < pos; index2++) {
std::cout << '-';
}
for (int index2 = pos; index2 < pos + (sizy >> 1) + 1; index2++) {
std::cout << '+';
}
for (int index2 = pos + (sizy >> 1) + 1; index2 < sizy; index2++) {
std::cout << '-';
}
pos += (sizy >> 1) + 1;
}
std::cout << '\n';
}
for (int index = (((sizx - 1) >> 1) * sizy) / ((sizy >> 1) + 1); index < sizx; index++) {
for (int index2 = 0; index2 < sizy; index2++) {
std::cout << '-';
}
std::cout << '\n';
}
}
else if (ans < sizx + (((sizy - 1) >> 1) * sizx) / ((sizx >> 1) + 1)) {
std::cout << sizx + (((sizy - 1) >> 1) * sizx) / ((sizx >> 1) + 1) << '\n';
for (int index = 0; index < sizx; index++) {
pos = 0;
for (int index2 = 0; index2 < (((sizy - 1) >> 1) * sizx) / ((sizx >> 1) + 1); index2++) {
if (pos + (sizx >> 1) + 1 > sizx) {
if (pos + (sizx >> 1) + 1 - sizx <= index && index < pos) {
std::cout << '+';
}
else {
std::cout << '-';
}
pos += (sizx >> 1) + 1 - sizx;
}
else {
if (pos <= index && index < pos + (sizx >> 1) + 1) {
std::cout << '-';
}
else {
std::cout << '+';
}
pos += (sizx >> 1) + 1;
}
}
for (int index2 = (((sizy - 1) >> 1) * sizx) / ((sizx >> 1) + 1); index2 < sizy; index2++) {
std::cout << '+';
}
std::cout << '\n';
}
}
else {
std::cout << ans << '\n';
for (int index = 0; index < sizx1; index++) {
for (int index2 = 0; index2 < sizy1; index2++) {
std::cout << '-';
}
for (int index2 = sizy1; index2 < sizy; index2++) {
std::cout << '+';
}
std::cout << '\n';
}
for (int index = sizx1; index < sizx2; index++) {
for (int index2 = 0; index2 < sizy; index2++) {
std::cout << '-';
}
std::cout << '\n';
}
for (int index = sizx2; index < sizx; index++) {
for (int index2 = 0; index2 < sizy2; index2++) {
std::cout << '+';
}
for (int index2 = sizy2; index2 < sizy; index2++) {
std::cout << '-';
}
std::cout << '\n';
}
}
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
288 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
288 KB |
Output is correct |
3 |
Correct |
2 ms |
208 KB |
Output is correct |
4 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
1256 KB |
Output is correct |
2 |
Correct |
26 ms |
1136 KB |
Output is correct |
3 |
Correct |
26 ms |
1052 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
1264 KB |
Output is correct |
2 |
Correct |
37 ms |
1104 KB |
Output is correct |
3 |
Correct |
31 ms |
924 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
288 KB |
Output is correct |
3 |
Correct |
2 ms |
208 KB |
Output is correct |
4 |
Correct |
2 ms |
332 KB |
Output is correct |
5 |
Correct |
30 ms |
1256 KB |
Output is correct |
6 |
Correct |
26 ms |
1136 KB |
Output is correct |
7 |
Correct |
26 ms |
1052 KB |
Output is correct |
8 |
Correct |
29 ms |
1264 KB |
Output is correct |
9 |
Correct |
37 ms |
1104 KB |
Output is correct |
10 |
Correct |
31 ms |
924 KB |
Output is correct |
11 |
Correct |
9 ms |
460 KB |
Output is correct |
12 |
Correct |
22 ms |
1012 KB |
Output is correct |
13 |
Correct |
29 ms |
1060 KB |
Output is correct |
14 |
Correct |
27 ms |
836 KB |
Output is correct |
15 |
Correct |
29 ms |
1176 KB |
Output is correct |
16 |
Correct |
23 ms |
960 KB |
Output is correct |
17 |
Correct |
10 ms |
544 KB |
Output is correct |