#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 1005;
char ans[N][N];
void Solve(){
int n, m;
cin >> n >> m;
bool bad = false;
if(n > m){
swap(n, m);
bad = true;
}
int i, j;
int res;
if(n <= 2){
for(i=0;i<n;i++)
for(j=0;j<m;j++)ans[i][j] = '-';
res = m;
}else if(n <= 4){
for(i=0;i<(n+2)/2;i++)
for(j=0;j<m;j++)ans[i][j] = '-';
for(i=(n+2)/2;i<n;i++)
for(j=0;j<m;j++)ans[i][j] = '+';
res = m+((n-1)/2);
}else {
for(i=0;i<n;i++)
for(j=0;j<m;j++)ans[i][j] = '-';
int have = 0;
i=0;
j=0;
int need = (n+2)/2;
int toans = 0;
while(true){
if(have == need)i++,have=0, toans++;
if(i == n)break;
ans[i][j] = '+';
j++;
if(j == m)j=0;
have++;
}res = toans + m;
}
cout << res << '\n';
if(bad){
for(i=0;i<n;i++)
for(j=0;j<m;j++)
if(ans[i][j] == '+')ans[i][j] = '-';
else ans[i][j] = '+';
for(j=0;j<m;j++){
for(i=0;i<n;i++)
cout << ans[i][j];
cout << '\n';
}
}else {
for(i=0;i<n;i++){
for(j=0;j<m;j++)
cout << ans[i][j];
cout << '\n';
}
}
}
signed main(){
int t;
cin >> t;
while(t--)Solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
2 ms |
364 KB |
Output is correct |
4 |
Incorrect |
4 ms |
364 KB |
in the table A+B is not equal to 34 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
45 ms |
1388 KB |
in the table A+B is not equal to 118 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
44 ms |
1536 KB |
in the table A+B is not equal to 48 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
2 ms |
364 KB |
Output is correct |
4 |
Incorrect |
4 ms |
364 KB |
in the table A+B is not equal to 34 |