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;
int main() {
long long t;
cin >> t;
for (int i = 0; i<t; i++){
int n,m;
cin >> n >> m;
if (n == 0 || m == 0){
cout << 0 << "\n";
}
else if (n ==1){
cout << m << "\n";
for (int k = 0; k<m;k++){
cout << "-";
}
cout << "\n";
}
else if(m == 1){
cout << n << "\n";
for (int k = 0; k < n;k++){
cout << "+" << "\n";
}
}
else if(m == 2){
cout << n << "\n";
for (int k = 0; k < n;k++){
cout << "++" << "\n";
}
}
else if(n == 2){
cout << m << "\n";
for (int k = 0; k < m;k++){
cout << "-";
}
cout << "\n";
for (int k = 0; k < m;k++){
cout << "-";
}
}else{
long long res = 0;
if (n >= m){
int z = 0;
vector<vector<char>> matrix(n, vector<char>(m, '+'));
res = n+m/2;
if (m%2 == 0){
res--;
z=1;
}
for (int k = 1+z; k < m; k+=2){
for (int j = 0; j<n ; j++){
matrix[j][k] = '-';
}
}
cout << res << "\n";
for (auto vec :matrix){
for (auto el:vec){
cout << el;
}
cout << "\n";
}
}
else if (n < m){
int z = 0;
vector<vector<char>> matrix(n, vector<char>(m, '-'));
res = m+n/2;
if (n%2 == 0){
res--;
z = 1;
}
for (int k = 1+z; k < n; k+=2){
for (int j = 0; j<m ; j++){
matrix[k][j] = '+';
}
}
cout << res << "\n";
for (auto vec :matrix){
for (auto el:vec){
cout << el;
}
cout << "\n";
}
}
}
}
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... |