#include <bits/stdc++.h>
using namespace std;
int t,n,m,pos,num,anss1,anss2,ct1[1005],ct2[1005];
char ans1[1005][1005],ans2[1005][1005];
int main(){
ios::sync_with_stdio(false);
cin >> t;
while (t--){
cin >> n >> m;
for (int i=1;i<=n;i++){
for (int j=1;j<=m;j++){
ans1[i][j]='+';
}
ct1[i]=0;
}
pos=1; anss1=n;
for (int i=1;i<=(n-1)/2*m/(n/2+1);i++){
for (int j=1;j<=n/2+1;j++){
if (ct1[pos]+1 >= m/2+1)
goto out;
ans1[pos][i]='-';
ct1[pos]++;
pos++;
if (pos == n+1)
pos=1;
}
anss1++;
}
out:;
for (int i=1;i<=n;i++){
for (int j=1;j<=m;j++){
ans2[i][j]='-';
ct2[j]=0;
}
}
pos=1; anss2=m;
for (int i=1;i<=(m-1)/2*n/(m/2+1);i++){
for (int j=1;j<=m/2+1;j++){
if (ct2[pos]+1 >= n/2+1)
goto out2;
ans2[i][pos]='+';
ct2[pos]++;
pos++;
if (pos == m+1)
pos=1;
}
anss2++;
}
out2:;
cout << max(anss1,anss2) << "\n";
if (anss1 > anss2){
for (int i=1;i<=n;i++){
for (int j=1;j<=m;j++){
cout << ans1[i][j];
}
cout << "\n";
}
}
else
{
for (int i=1;i<=n;i++){
for (int j=1;j<=m;j++){
cout << ans2[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 |
492 KB |
in the table A+B is not equal to 21 |
# |
결과 |
실행 시간 |
메모리 |
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 |
Correct |
38 ms |
1644 KB |
Output is correct |
2 |
Correct |
34 ms |
2796 KB |
Output is correct |
3 |
Correct |
31 ms |
3052 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
36 ms |
1644 KB |
Output is correct |
2 |
Correct |
30 ms |
2668 KB |
Output is correct |
3 |
Correct |
28 ms |
2284 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |