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;
#define pb push_back
#define ll long long
#define ull unsigned long long
#define ssort sort(s.begin(),s.end());
#define sreverse reverse(s.begin(),s.end());
#define sclear s.clear();
#define ssize s.size();
#define ld long double
#define F first
#define S second
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define sq(a) (a)*(a)
ll a,b,c,e,d,f,k,g,h,r,i,j,x,y,z,m,n,l,t,p,s,u,sum,ans,mod=1e18;
ll q[200][200],qr[200][200];
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cin>>a;
for(i=1;i<=a;i++)
{
cin>>n>>m;
if(n==1&&m==1){
cout<<1<<endl<<'+'<<endl; continue;
}
////////////////////////////////////////////////////////////////////////////////
if(n==m){
l=-1;
for(j=1;j<=m;j++)
{
if(j%2==1) l+=2;
else l++;
}
cout<<l<<endl; l=0;
if(n%2==1){
for(j=1;j<=m;j++)
{
for(k=1;k<=m;k++)
{
if(k%2==1) cout<<'+';
else cout<<'-';
}
cout<<endl;
}
}
else{
for(j=1;j<=m;j++)
{
for(k=1;k<m;k++)
{
if(k%2==1) cout<<'+';
else cout<<'-';
}
cout<<'+'<<endl;
}
}
continue;
}
////////////////////////////////////////////////////////////////////////////////
if(m!=n){
if(m>n){
k=m+(n)/2;
if(n%2==0) k--;
cout<<k<<endl;
if(n%2==1){
for(j=1;j<=n;j++)
{
for(k=1;k<=m;k++)
{
if(j%2==1) cout<<'-';
else cout<<'+';
}
cout<<endl;
}
}
else{
for(j=1;j<n;j++)
{
for(k=1;k<=m;k++)
{
if(j%2==1) cout<<'-';
else cout<<'+';
}
cout<<endl;
}
}
if(n>1){
for(k=1;k<=m;k++)
{
cout<<'-';
}
cout<<endl;
}
}
else{
k=n+(m)/2;
if(m%2==0) k--;
cout<<k<<endl;
if(m%2==0){
for(j=1;j<=n;j++)
{
for(k=1;k<m;k++)
{
if(k%2==1) cout<<'+';
else cout<<'-';
}
cout<<'+'<<endl;
}
}
else{
for(j=1;j<=n;j++)
{
for(k=1;k<=m;k++)
{
if(k%2==1) cout<<'+';
else cout<<'-';
}
cout<<endl;
}
}
}
}
}
}
# | 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... |