This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
void fun()
{
long long n,m;
cin>>n>>m;
bool swp=0;
if(m>n)
{
swap(n,m);
swp=1;
}
char ch[n+5][m+5];
for(long long i=1;i<=n;i++)
{
for(long long j=1;j<=m;j++)
{
ch[i][j]='+';
}
}
long long mx_can_in_row=(m-1)/2;
long long mn_ned_st=(n+1)/2;
long long zarc=0,st=1;
for(long long i=0;i<mx_can_in_row;i++)
{
for(long long j=1;(j<=n && st<=m);j++)
{
ch[j][st]='-';
zarc++;
if(zarc>=mn_ned_st)
{
st++;
zarc=0;
}
}
}
long long ans=n;
for(long long j=1;j<=m;j++)
{
long long km=0;
for(long long i=1;i<=n;i++)
{
km+=(ch[i][j]=='-');
}
ans+=(km>=mn_ned_st);
}
cout<<ans<<"\n";
if(swp)
{
for(long long j=1;j<=m;j++)
{
for(long long i=1;i<=n;i++)
{
if(ch[i][j]=='+')
{
cout<<"-";
}
else
{
cout<<"+";
}
}
cout<<"\n";
}
}
else
{
for(long long i=1;i<=n;i++)
{
for(long long j=1;j<=m;j++)
{
cout<<ch[i][j];
}
cout<<"\n";
}
}
return;
}
int main()
{
cin.tie(0);
ios_base::sync_with_stdio(0);
long long t;
cin>>t;
while(t--)
{
fun();
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |