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 solve(){
int n,m;
cin >> n >> m;
bool ch=0;
if(n>m){
swap(n,m);
ch=1;
}
int a[n+1][m+1];
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
a[i][j]=1;
}
}
if(n<=2){
if(ch){
cout << m << endl;
for(int i=1;i<=m;i++){
for(int j=1;j<=n;j++){
cout << '+';
}
cout << endl;
}
}else{
cout << m << endl;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cout << '-';
}
cout << endl;
}
}
}else{
int s=n;
int q=(m+1)/2;
int z=(n/2)+1;
//cout << z << endl;
for(int i=1;i<=z;i++){
for(int j=2;j<=q;j++){
a[i][j]=0;
}
}
s+=(q-1);
int k=(m-q-1);
q++;
if(n%2==1){
if(k>1){
s--;
s+=k;
int l=n-z+1;
for(int i=l;i<=n;i++){
for(int j=q;j<m;j++){
a[i][j]=0;
}
}
}
}else{
if(k>2){
s-=2;
s+=k;
int l=n-z+1;
for(int i=l;i<=n;i++){
for(int j=q;j<m;j++){
a[i][j]=0;
}
}
}
}
if(ch){
cout << s << endl;
for(int i=1;i<=m;i++){
for(int j=1;j<=n;j++){
if(a[j][i]!=0)cout << '-';
else cout << '+';
}
cout << endl;
}
}else{
cout << s << endl;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(a[i][j]!=0)cout << '+';
else cout << '-';
}
cout << endl;
}
}
}
}
int main(){
int t;
cin >> t;
while(t--){
solve();
}
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... |