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 int long long
#define sp << ' ' <<
#define nl << '\n'
bool e(int y){ return !(y%2); } // lol
signed main(){
cin.tie(0)->sync_with_stdio(0);
int T; cin >> T;
while(T--){
int n, m; cin >> n >> m;
if(e(m) and ((e(n) and m > n) or !e(n))){
cout << m + max(0LL, n - (m/2 + 1)) nl;
for(int i=0; i<n; ++i){
for(int j=0; j<m; ++j){
cout << (i+i > n ? '+' : '-');
}cout nl;
}
}else if(e(n)){
cout << n + max(0LL, m - (n/2 + 1)) nl;
for(int i=0; i<n; ++i){
for(int j=0; j<m; ++j){
cout << (j+j > m ? '-' : '+');
}cout nl;
}
}else if(n==1){
cout << m nl;
for(int i=0; i<m; ++i) cout << '-';
cout nl;
}else if(m==1){
cout << n nl;
for(int i=0; i<n; ++i) cout << '+' nl;
}else{
cout << n + m - 2 nl;
for(int i=0; i<n; ++i){
for(int j=0; j<m; ++j){
if(i and j) cout << ((i+j) % 2 ? '+' : '-');
else cout << (i ? '+' : '-');
}
cout nl;
}
}
}
}
# | 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... |