#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;
//7 5
//(n-1)/2*m / (n/2+1) or (n-1)/2*m /(m+1)/2
cout << max((n-1)/2*m/(n/2+1)+n,(m-1)/2*n/(m/2+1)+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]='+';
}
}
num=(n-1)/2*m; pos=1;
for (int i=1;i<=num/(n/2+1);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]='-';
}
}
num=(m-1)/2*n; pos=1;
for (int i=1;i<=num/(m/2+1);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 |
384 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 47 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
in the table A+B is not equal to 5 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
37 ms |
1516 KB |
in the table A+B is not equal to 117 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
34 ms |
1516 KB |
Output is correct |
2 |
Correct |
28 ms |
1900 KB |
Output is correct |
3 |
Correct |
25 ms |
1644 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
in the table A+B is not equal to 5 |