#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
int i,j,p,q,n,m,k;
int T;
char ans[1006][1006];
int do_count()
{
int otg = 0;
for(i=1;i<=n;i++)
{
int br = 0;
for(j=1;j<=m;j++)
{
// cout<<ans[i][j]<<" "<<br<<endl;
if(ans[i][j]=='+')
br++;
}
// cout<<i<<" "<<br<<endl;
if(br>=m/2+1)otg++;
}
for(i=1;i<=m;i++)
{
int br = 0;
for(j=1;j<=n;j++)
{
if(ans[j][i]=='-')
br++;
}
if(br>=n/2+1)otg++;
}
return otg;
}
void solve()
{
cin>>n>>m;
for(i=1;i<=n;i++)
{
for(j=1;j<=m;j++)
{
ans[i][j] = '&';
}
}
if(n==1)
{
cout<<m<<endl;
for(j=1;j<=m;j++)
cout<<'-';
cout<<endl;
return ;
}
if(m==1)
{
cout<<n<<endl;
for(j=1;j<=n;j++)
cout<<'+'<<endl;
return ;
}
if(n==2 || m==2)
{
char znak = '+';
if(m>n)znak = '-';
for(i=1;i<=n;i++)
for(j=1;j<=m;j++)
ans[i][j]=znak;
cout<<do_count()<<endl;
for(i=1;i<=n;i++)
{
for(j=1;j<=m;j++)
cout<<ans[i][j];
cout<<endl;
}
return ;
}
int non_dom = n/2;
int non_domm = m/2;
if(m%2==0)
non_domm--;
if(n%2==0)
non_dom--;
for(i=1;i<=non_dom;i++)
{
for(j=1;j<=m/2+1;j++)
ans[i][j]='+';
}
for(i=non_dom+1;i<=n;i++)
{
for(j=1;j<=non_domm;j++)
ans[i][j]='-';
}
for(i=1;i<=n/2+1;i++)
{
for(j=m/2+2;j<=m;j++)
ans[i][j]='-';
}
for(i=1;i<=n;i++)
{
for(j=1;j<=m;j++)
{
if(ans[i][j]=='&')
ans[i][j]='+';
}
}
if(n==4 && m==4)
ans[2][4]=ans[3][4]='+';
cout<<do_count()<<endl;
for(i=1;i<=n;i++)
{
for(j=1;j<=m;j++)
cout<<ans[i][j];
cout<<endl;
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>T;
while(T--)
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Wrong answer in test 4 3: 4 < 5 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Wrong answer in test 4 3: 4 < 5 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Wrong answer in test 4 3: 4 < 5 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
1324 KB |
Output is correct |
2 |
Correct |
22 ms |
1868 KB |
Output is correct |
3 |
Correct |
21 ms |
2024 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
23 ms |
1444 KB |
Wrong answer in test 6 6: 8 < 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Wrong answer in test 4 3: 4 < 5 |
3 |
Halted |
0 ms |
0 KB |
- |