#include<bits/stdc++.h>
using namespace std;
#define ll long long
char arr[1005][1005];
void fun(){
bool boo = 0;
ll n, m;
cin>>n>>m;
if(n > m)swap(n, m), boo = 1;
for(int i = 1; i <= n; i++)
for(int j = 1; j <= m; j++)
arr[i][j] = (boo ? '+' : '-');
cout<<max(n, m) + min(min(n, m), (min(n, m) / 2 - !(min(n, m) & 1)) * max(n, m) / (max(n, m) / 2 + 1))<<endl;
for(int i = 1, last = 1; i <= min(min(n, m), (min(n, m) / 2 - !(min(n, m) & 1)) * max(n, m) / (max(n, m) / 2 + 1)); i++){
for(int j = 1; j <= m / 2 + 1; j++, last++){
if(last == m + 1)last = 1;
arr[i][last] = (boo ? '-' : '+');
}
}
if(!boo){
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++)
cout<<arr[i][j];
cout<<"\n";
}
}
else{
for(int i = 1; i <= m; i++){
for(int j = 1; j <= n; j++)
cout<<arr[j][i];
cout<<"\n";
}
}
cout<<"\n";
}
int main(){
int ttt = 1;
cin>>ttt;
while(ttt--)fun();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
2 ms |
212 KB |
Output is correct |
4 |
Correct |
3 ms |
288 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
1324 KB |
Output is correct |
2 |
Correct |
27 ms |
1856 KB |
Output is correct |
3 |
Correct |
27 ms |
1820 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
1396 KB |
Output is correct |
2 |
Correct |
24 ms |
1732 KB |
Output is correct |
3 |
Correct |
22 ms |
1492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
2 ms |
212 KB |
Output is correct |
4 |
Correct |
3 ms |
288 KB |
Output is correct |
5 |
Correct |
31 ms |
1324 KB |
Output is correct |
6 |
Correct |
27 ms |
1856 KB |
Output is correct |
7 |
Correct |
27 ms |
1820 KB |
Output is correct |
8 |
Correct |
29 ms |
1396 KB |
Output is correct |
9 |
Correct |
24 ms |
1732 KB |
Output is correct |
10 |
Correct |
22 ms |
1492 KB |
Output is correct |
11 |
Correct |
10 ms |
468 KB |
Output is correct |
12 |
Correct |
23 ms |
1576 KB |
Output is correct |
13 |
Correct |
27 ms |
1484 KB |
Output is correct |
14 |
Correct |
18 ms |
1296 KB |
Output is correct |
15 |
Correct |
31 ms |
2252 KB |
Output is correct |
16 |
Correct |
22 ms |
1748 KB |
Output is correct |
17 |
Correct |
10 ms |
1072 KB |
Output is correct |