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 speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
char c[1024][1024];
int cnt[1024];
void read()
{
memset(cnt,0,sizeof(cnt));
int n,m;
cin>>n>>m;
bool s=0;
if(m<n)s=1,swap(n,m);
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
c[i][j]='-';
}
}
int j=1;
int ans=m;
for(int i=1;i<=n;i++)
{
int curr=m/2+1;
while(curr)
{
if(cnt[j]==n-n/2-1)break;
cnt[j]++;
c[i][j]='+';
curr--;
j++;
if(j==m+1)j=1;
}
if(curr)break;
ans++;
}
cout<<ans<<endl;
if(s)
{
for(int j=1; j<=m; j++)
{
for(int i=1; i<=n; i++)
{
if(c[i][j]=='-')cout<<"+";
else cout<<"-";
}
cout<<endl;
}
}
else
{
for(int i=1; i<=n; i++)
{
for(int j=1; j<=m; j++)
{
cout<<c[i][j];
}
cout<<endl;
}
}
}
int main()
{
speed();
int t;
cin>>t;
while(t--)
read();
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... |