#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef long long int ll;
void S()
{
int n, m;
cin >> n >> m;
bool swaped = 0;
char red = '+', blue = '-';
if(n < m)
swap(n, m), swaped = 1, swap(red, blue);
char a[n][m];
for(int i = 0; i < n; i ++)
for(int j = 0; j < m; j ++)
a[i][j] = red;
int ans = n, cnt = 0;
for(int k = 0; k < (m-1)/2; k ++){
for(int i = 0; i < n; i ++){
a[i][ans-n] = blue;
cnt ++;
// cout << cnt << " ";
if(cnt == (n/2)+1)
ans ++, cnt = 0;//, cout << cnt << " ", cnt = 0;
}
}
cout << ans << "\n";
if(!swaped){
for(int i = 0; i < n; i ++){
for(int j = 0; j < m; j ++)
cout << a[i][j];
cout << "\n";
}
}
else{
for(int i = 0; i < m; i ++){
for(int j = 0; j <n; j ++)
cout << a[j][i];
cout << "\n";
}
}
}
int main() {
IOS;
int t;
cin >> t;
while(t --)
S();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
24 ms |
1308 KB |
Output is correct |
2 |
Correct |
22 ms |
1752 KB |
Output is correct |
3 |
Correct |
20 ms |
1848 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
21 ms |
1228 KB |
Output is correct |
2 |
Correct |
17 ms |
1540 KB |
Output is correct |
3 |
Correct |
17 ms |
1332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
2 ms |
332 KB |
Output is correct |
5 |
Correct |
24 ms |
1308 KB |
Output is correct |
6 |
Correct |
22 ms |
1752 KB |
Output is correct |
7 |
Correct |
20 ms |
1848 KB |
Output is correct |
8 |
Correct |
21 ms |
1228 KB |
Output is correct |
9 |
Correct |
17 ms |
1540 KB |
Output is correct |
10 |
Correct |
17 ms |
1332 KB |
Output is correct |
11 |
Correct |
6 ms |
460 KB |
Output is correct |
12 |
Correct |
18 ms |
1492 KB |
Output is correct |
13 |
Correct |
18 ms |
1388 KB |
Output is correct |
14 |
Correct |
15 ms |
1060 KB |
Output is correct |
15 |
Correct |
22 ms |
2252 KB |
Output is correct |
16 |
Correct |
20 ms |
1700 KB |
Output is correct |
17 |
Correct |
7 ms |
844 KB |
Output is correct |