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 ll long long
#define pii pair<int,int>
using namespace std;
const int mxn=1e5+5;
const int inf=1e9;
void solve() {
int n, m;
cin >> n >> m;
int b[n][m], res = 0;
for(int i = 0; i < (1 << (n * m)); i++) {
int a[n][m];
for(int j = 0; j < n; j++) {
for(int k = 0; k < m; k++) {
a[j][k] = (i >> (j * m + k)) & 1;
}
}
int ans = 0;
for(int j = 0; j < n; j++) {
int c = 0;
for(int k = 0; k < m; k++) c += a[j][k];
if(c > m / 2) ans++;
}
for(int j = 0; j < m; j++) {
int c = 0;
for(int k = 0; k < n; k++) {
c += 1 - a[k][j];
}
if(c > n / 2) ans++;
}
if(ans > res) {
res = ans;
for(int j = 0; j < n; j++) for(int k = 0; k < m; k++) b[j][k] = a[j][k];
}
}
cout<<res<<endl;
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++) {
if(b[i][j]) cout<<"+";
else cout<<"-";
}
cout<<endl;
}
}
int main() {
int t;
cin >> t;
while(t--) solve();
}
# | 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... |