#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;
int main() {
long long t;
cin >> t;
while (t--) {
int ans,n,m,maxl,addl,needed,check,q,w,plus=0;
ans = 0;
cin >> n >> m;
char table[n][m];
bool bosoo;
if (n>=m)
{
maxl = n;
addl = ((m-(m/2+1))*n)/(n/2+1);
bosoo = true;
memset(table,'+',sizeof table);
needed = n/2+1;
}else{
maxl = m;
addl = ((n-(n/2+1))*m)/(m/2+1);
bosoo = false;
memset(table,'-',sizeof table);
needed = m/2+1;
}
ans = maxl + addl;
cout << ans<<endl;
check = needed*addl;
q=0;
w=0;
while (check>0 && bosoo == false)
{
table[q][w]='+';
w++;
check--;
plus++;
if (plus==maxl/2+1)
{
q++;
plus=0;
}
if (w==maxl)
{
w=0;
}
}
while (check>0 && bosoo == true)
{
table[w][q]='-';
w++;
check--;
plus++;
if (plus==maxl/2+1)
{
q++;
plus=0;
}
if (w==maxl)
{
w=0;
}
}
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
cout << table[i][j];
}
cout << '\n';
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
500 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
2 ms |
500 KB |
Output is correct |
4 |
Correct |
3 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
1348 KB |
Output is correct |
2 |
Correct |
20 ms |
1880 KB |
Output is correct |
3 |
Correct |
20 ms |
1880 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
1368 KB |
Output is correct |
2 |
Correct |
20 ms |
1624 KB |
Output is correct |
3 |
Correct |
21 ms |
1632 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
2 ms |
500 KB |
Output is correct |
4 |
Correct |
3 ms |
344 KB |
Output is correct |
5 |
Correct |
24 ms |
1348 KB |
Output is correct |
6 |
Correct |
20 ms |
1880 KB |
Output is correct |
7 |
Correct |
20 ms |
1880 KB |
Output is correct |
8 |
Correct |
22 ms |
1368 KB |
Output is correct |
9 |
Correct |
20 ms |
1624 KB |
Output is correct |
10 |
Correct |
21 ms |
1632 KB |
Output is correct |
11 |
Correct |
9 ms |
600 KB |
Output is correct |
12 |
Correct |
17 ms |
1368 KB |
Output is correct |
13 |
Correct |
19 ms |
1368 KB |
Output is correct |
14 |
Correct |
14 ms |
1112 KB |
Output is correct |
15 |
Correct |
23 ms |
2392 KB |
Output is correct |
16 |
Correct |
18 ms |
1884 KB |
Output is correct |
17 |
Correct |
8 ms |
856 KB |
Output is correct |