#include <bits/stdc++.h>
#define ll long long
#define x first
#define y second
using namespace std;
int main (){
ll t;
cin>>t;
while (t--)
{
ll n,m;
cin>>n>>m;
char g[n+1][m+1];
ll n1=(n+2)/2;
ll m1=(m+2)/2;
ll n2=(n-1)/2;
ll m2=(m-1)/2;
if (n>=m)
{
for (int i=1;i<=n;i++)
for (int k=1;k<=m;k++)
g[i][k]='+';
ll ans=n;
vector<pair<ll,ll> >tk;
tk.resize(n+1);
for (int i=0;i<=n;i++)
tk[i].x=0,tk[i].y=i;
for (int i=1;i<=m;i++)
{
sort(tk.begin()+1,tk.end());
if (tk[n1].x==m2)break;
for (int k=1;k<=n1;k++)
{
// cout<<k<<' '<<tk[k].x<<endl<<"sdfsadfsaf"<<endl;
tk[k].x++;
g[tk[k].y][i]='-';
}
ans++;
}
cout<<ans<<endl;
for (int i=1;i<=n;i++)
{
for (ll k=1;k<=m;k++)
cout<<g[i][k]<<' ';
cout<<endl;
}
}
else
{
for (int i=1;i<=n;i++)
for (int k=1;k<=m;k++)
g[i][k]='-';
ll ans=m;
vector<pair<ll,ll> >tk;
tk.resize(m+1);
for (int i=0;i<=m;i++)
tk[i].x=0,tk[i].y=i;
for (int i=1;i<=n;i++)
{
sort(tk.begin()+1,tk.end());
if (tk[m1].x==n2)break;
for (int k=1;k<=m1;k++)
{
// cout<<k<<' '<<tk[k].x<<endl<<"sdfsadfsaf"<<endl;
tk[k].x++;
g[i][tk[k].y]='+';
}
ans++;
}
cout<<ans<<endl;
for (int i=1;i<=n;i++)
{
for (ll k=1;k<=m;k++)
cout<<g[i][k]<<' ';
cout<<endl;
}
}
}
return 0;}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Wrong answer |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
15 ms |
376 KB |
Wrong answer |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Wrong answer |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
150 ms |
2436 KB |
Wrong answer |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
123 ms |
2400 KB |
Wrong answer |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Wrong answer |
2 |
Halted |
0 ms |
0 KB |
- |