This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/** @kutbilimone **/
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
void solve(){
int n, m;
cin >> n >> m;
bool swapped = (n > m);
char blue = '-', red = '+';
if(n > m) swap(n, m), swap(blue, red);
vector< vector<char> > a(n, vector<char> (m, blue));
vector<int> col(m, n);
int res = m;
for(int i = 0, j = 0; i < n; i++){
for(int k = m/2+1, cntl = 0; k > 0; k--, j++){
j %= m;
if(col[j]-1 < n/2+1) continue;
a[i][j] = red;
cntl++;
if(cntl == m/2+1) res++;
col[j]--;
}
}
cout << res << endl;
for(int i = 0; i < (swapped ? m : n); i++){
for(int j = 0; j < (swapped ? n : m); j++){
cout << (swapped ? a[j][i] : a[i][j]);
}
cout << endl;
}
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
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... |