#include<bits/stdc++.h>
using namespace std;
void solve()
{
int n,m;
cin>>n>>m;
char ans1[n][m],ans2[n][m];
int a1=n,a2=m;
vector<int>v1(n,0),v2(m,0);
for(int j=0;j<m;j++)
{
int cnt=0;
for(int i=0;i<n;i++)
{
if(v1[i]<(m+1)/2-1)cnt++;
}
if(cnt>n/2)
{
a1++;
int num=n/2+1;
for(int i=0;i<n;i++)
{
if(v1[i]<m/2 && num!=0)
{
v1[i]++;
num--;
ans1[i][j]='-';
}
else ans1[i][j]='+';
}
}
else for(int i=0;i<n;i++)ans1[i][j]='+';
}
for(int i=0;i<n;i++)
{
int cnt=0;
for(int j=0;j<m;j++)
{
if(v2[j]<(n+1)/2-1)cnt++;
}
if(cnt>m/2)
{
a2++;
int num=m/2+1;
for(int j=0;j<m;j++)
{
if(v2[j]<n/2 && num!=0)
{
v2[j]++;
num--;
ans2[i][j]='+';
}
else ans2[i][j]='-';
}
}
else for(int j=0;j<m;j++)ans2[i][j]='-';
}
cout<<max(a1,a2)<<endl;
if(a2>a1)
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
cout<<ans2[i][j];
cout<<endl;
}
else
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
cout<<ans1[i][j];
cout<<endl;
}
}
int main()
{
int t;
cin>>t;
while(t--)solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
268 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
268 KB |
Output is correct |
3 |
Correct |
6 ms |
204 KB |
Output is correct |
4 |
Incorrect |
11 ms |
332 KB |
Wrong answer in test 5 29: 31 < 32 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
54 ms |
1200 KB |
Wrong answer in test 97 21: 107 < 116 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
46 ms |
1308 KB |
Wrong answer in test 24 24: 35 < 44 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
268 KB |
Output is correct |
3 |
Correct |
6 ms |
204 KB |
Output is correct |
4 |
Incorrect |
11 ms |
332 KB |
Wrong answer in test 5 29: 31 < 32 |