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>
#define int long long
#define pb push_back
#define mp make_pair
using namespace std;
const int mod = 1e9 + 7;
const int inf = 1e12*2;
const int N = 2e5 + 5;
int32_t main(){
cin.tie(0); cout.tie(0);
ios_base::sync_with_stdio(false);
int t;
cin>>t;
while(t--){
int n, m;
cin>>n>>m;
if(n%2 == 1 && m%2 == 1){
if(n == 1){
cout<<m<<endl;
for(int i = 0; i < m; i++){
cout<<"-";
}
cout<<endl;
}
else if(m == 1){
cout<<n<<endl;
for(int i = 0; i < n; i++){
cout<<"+"<<endl;
}
}
else{
cout<<n + m - 2<<endl;
vector<vector<char> > a(n, vector<char>(m, '-'));
for(int i = 0; i < n/2; i++){
for(int j = 0; j < m/2; j++){
a[i][j] = '+';
a[n - i - 1][m - j - 1] = '+';
}
}
for(int i = 0; i < n; i++){
a[i][m/2] = '+';
}
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
cout<<a[i][j];
}
cout<<endl;
}
}
}
else{
int bcol = m - ((m+1) / 2), rrow = n - ((n+1)/2);
if(n + bcol > m + rrow){
cout<<n+bcol<<endl;
vector<vector<char> > a(n, vector<char>(m, '+'));
for(int i = 0; i < n; i++){
for(int j = 0; j < bcol; j++){
a[i][j] = '-';
}
}
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
cout<<a[i][j];
}
cout<<endl;
}
}
else{
cout<<m+rrow<<endl;
vector<vector<char> > a(n, vector<char>(m, '-'));
for(int i = 0; i < rrow; i++){
for(int j = 0; j < m; j++){
a[i][j] = '+';
}
}
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
cout<<a[i][j];
}
cout<<endl;
}
}
}
}
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... |