This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// quit the talkin', cut the check!
#include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define nptr nullptr
using namespace std;
const int MAXN = 2e4 + 1;
const ll MOD = 1e9 + 7;
const int INF = 2e9;
const ll INFLL = 1e18;
const ld PI = acos(-1);
void solve() {
int n, m;
cin >> n >> m;
char a[n][m];
if(n > m){
for(int i = 0; i < m; ++i){
for(int j = 0; j < n; ++j){
if(i >= 1 + !(m & 1) && ((i - (1 + !(m & 1))) % 2 == 0 && j <= n / 2)){
a[j][i] = '-';
}
else a[j][i] = '+';
}
}
}
else{
for(int i = 0; i < n; ++i){
for(int j = 0; j < m; ++j){
if(i >= 1 + !(n & 1) && ((i - (1 + !(n & 1))) % 2 == 0 && j <= m / 2)){
a[i][j] = '+';
}
else a[i][j] = '-';
}
}
}
int ans = 0;
for(int i = 0; i < n; ++i){
int sum = 0;
for(int j = 0; j < m; ++j){
sum += bool(a[i][j] == '+');
}
ans += bool(sum > m / 2);
}
for(int j = 0; j < m; ++j){
int sum = 0;
for(int i = 0; i < n; ++i){
sum += bool(a[i][j] == '-');
}
ans += bool(sum > n / 2);
}
cout << ans << '\n';
for(int i = 0; i < n; ++i, cout << '\n'){
for(int j = 0; j < m; ++j){
cout << a[i][j];
}
}
}
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
//freopen("brokeday.in","r",stdin);
//freopen("richday.out","w",stdout);
int t = 1;
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... |