#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
void solve(){
int n, m;
cin >> n >> m;
bool swaped=false;
if(n<m){
int temp = n;
n=m;
m=temp;
swaped=true;
}
char a[n][m];
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
a[i][j]='+';
}
}
int x = 0, ans=n, y=0;
for(int i=0; i<(m-1)/2; i++){
for(int j=0; j<n; j++){
a[j][y]='-';
x++;
if(x==(n/2)+1){
ans++;
y++;
x=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++){
if(a[j][i]=='+'){
cout << '-';
}
else{
cout << '+';
}
}
cout << "\n";
}
}
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while(t--){
solve();
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
2 ms |
308 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
1288 KB |
Output is correct |
2 |
Correct |
21 ms |
1840 KB |
Output is correct |
3 |
Correct |
21 ms |
1832 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
1192 KB |
Output is correct |
2 |
Correct |
17 ms |
1612 KB |
Output is correct |
3 |
Correct |
16 ms |
1356 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
2 ms |
308 KB |
Output is correct |
5 |
Correct |
23 ms |
1288 KB |
Output is correct |
6 |
Correct |
21 ms |
1840 KB |
Output is correct |
7 |
Correct |
21 ms |
1832 KB |
Output is correct |
8 |
Correct |
23 ms |
1192 KB |
Output is correct |
9 |
Correct |
17 ms |
1612 KB |
Output is correct |
10 |
Correct |
16 ms |
1356 KB |
Output is correct |
11 |
Correct |
7 ms |
448 KB |
Output is correct |
12 |
Correct |
18 ms |
1472 KB |
Output is correct |
13 |
Correct |
18 ms |
1408 KB |
Output is correct |
14 |
Correct |
20 ms |
1016 KB |
Output is correct |
15 |
Correct |
24 ms |
2224 KB |
Output is correct |
16 |
Correct |
18 ms |
1740 KB |
Output is correct |
17 |
Correct |
7 ms |
844 KB |
Output is correct |