#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 >> (i * m + j)) & 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 |
1 |
Correct |
1 ms |
300 KB |
Output is correct |
2 |
Incorrect |
5 ms |
212 KB |
Wrong answer in test 2 1: 1 < 2 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2083 ms |
212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
300 KB |
Output is correct |
2 |
Incorrect |
5 ms |
212 KB |
Wrong answer in test 2 1: 1 < 2 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2057 ms |
212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2068 ms |
332 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
300 KB |
Output is correct |
2 |
Incorrect |
5 ms |
212 KB |
Wrong answer in test 2 1: 1 < 2 |
3 |
Halted |
0 ms |
0 KB |
- |