#include <bits/stdc++.h>
using namespace std;
int t,n,m,pos,num;
char ans[1005][1005];
int main(){
ios::sync_with_stdio(false);
cin >> t;
while (t--){
cin >> n >> m;
cout << max(min((n-1)/2*m/(n/2+1),(m-1)/2)+n,min((m-1)/2*n/(m/2+1),(n-1)/2)+m) << "\n";
if ((n-1)/2*m/(n/2+1)+n > (m-1)/2*n/(m/2+1)+m){
for (int i=1;i<=n;i++){
for (int j=1;j<=m;j++){
ans[i][j]='+';
}
}
pos=1;
for (int i=1;i<=min((n-1)/2*m/(n/2+1),(m-1)/2);i++){
for (int j=1;j<=n/2+1;j++){
ans[pos][i]='-';
pos++;
if (pos == n+1)
pos=1;
}
}
}
else
{
for (int i=1;i<=n;i++){
for (int j=1;j<=m;j++){
ans[i][j]='-';
}
}
pos=1;
for (int i=1;i<=min((m-1)/2*n/(m/2+1),(n-1)/2);i++){
for (int j=1;j<=m/2+1;j++){
ans[i][pos]='+';
pos++;
if (pos == m+1)
pos=1;
}
}
}
for (int i=1;i<=n;i++){
for (int j=1;j<=m;j++){
cout << ans[i][j];
}
cout << "\n";
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
in the table A+B is not equal to 5 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
364 KB |
in the table A+B is not equal to 5 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
in the table A+B is not equal to 5 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
36 ms |
1524 KB |
Wrong answer in test 97 21: 107 < 116 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
34 ms |
1536 KB |
Wrong answer in test 24 24: 35 < 44 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
in the table A+B is not equal to 5 |