이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
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--;
if(k==31) 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;
}
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... |