#include<bits/stdc++.h>
using namespace std;
#define int long long
vector < vector < char > > arr(1005 , vector < char > (1005));
void solve(){
bool bl = 0;
int n, m;
cin>>n>>m;
if(n > m){
swap(n, m);
bl = 1;
}
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
arr[i][j] = (bl ? '+' : '-');
}
}
cout<<max(n, m) + min(min(n, m), (min(n, m) / 2 - !(min(n, m) & 1)) * max(n, m) / (max(n, m) / 2 + 1))<<"\n";
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] = (bl ? '-' : '+');
}
}
if(bl == 0){
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";
}
signed main(){
int tt = 1;
cin>>tt;
while(tt--)solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1236 KB |
Output is correct |
2 |
Correct |
1 ms |
1236 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
1236 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1236 KB |
Output is correct |
2 |
Correct |
1 ms |
1236 KB |
Output is correct |
3 |
Correct |
3 ms |
1236 KB |
Output is correct |
4 |
Correct |
4 ms |
1364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
38 ms |
2332 KB |
Output is correct |
2 |
Correct |
32 ms |
2116 KB |
Output is correct |
3 |
Correct |
31 ms |
2136 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
37 ms |
2208 KB |
Output is correct |
2 |
Correct |
34 ms |
2124 KB |
Output is correct |
3 |
Correct |
28 ms |
2004 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1236 KB |
Output is correct |
2 |
Correct |
1 ms |
1236 KB |
Output is correct |
3 |
Correct |
3 ms |
1236 KB |
Output is correct |
4 |
Correct |
4 ms |
1364 KB |
Output is correct |
5 |
Correct |
38 ms |
2332 KB |
Output is correct |
6 |
Correct |
32 ms |
2116 KB |
Output is correct |
7 |
Correct |
31 ms |
2136 KB |
Output is correct |
8 |
Correct |
37 ms |
2208 KB |
Output is correct |
9 |
Correct |
34 ms |
2124 KB |
Output is correct |
10 |
Correct |
28 ms |
2004 KB |
Output is correct |
11 |
Correct |
11 ms |
1548 KB |
Output is correct |
12 |
Correct |
28 ms |
2004 KB |
Output is correct |
13 |
Correct |
29 ms |
2132 KB |
Output is correct |
14 |
Correct |
22 ms |
1876 KB |
Output is correct |
15 |
Correct |
42 ms |
2312 KB |
Output is correct |
16 |
Correct |
27 ms |
1964 KB |
Output is correct |
17 |
Correct |
14 ms |
1620 KB |
Output is correct |