#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<random>
#include<cmath>
#include<stack>
#include<map>
#include <iomanip>
#include <queue>
#include <set>
using namespace std;
using ll = long long;
using ull = unsigned long long;
ll mod = 1e9 + 7;
ll pv(ll a, ll b) {
if (b == 0)return 1;
ll res = (pv(a, b / 2));
if (b % 2) {
return (((res * res) % mod) * (a % mod)) % mod;
}
else {
return (res * res) % mod;
}
}
ll gcd(ll a, ll b) {
while (b) {
a %= b;
swap(a, b);
}
return a;
}
void solve() {
int n, m; cin >> n >> m;
int mx = 0;
vector<vector<int>>ansik;
for (int p = 0; p < (1 << (n * m)); p++) {
vector<vector<int>>v(n, vector<int>(m));
for (int j = 0; j < n * m; j++) {
if (p & (1 << j)) {
v[j / m][j % m]++;
}
}
int ans = 0;
for (int i = 0; i < n; i++) {
int cnt = 0;
for (int j = 0; j < m; j++) {
if (v[i][j])cnt++;
else cnt--;
}
if (cnt>=1)ans++;
}
for (int j = 0; j < m; j++) {
int cnt = 0;
for (int i = 0; i < n; i++) {
if (v[i][j] == 0)cnt++;
else cnt--;
}
if (cnt>=1)ans++;
}
if (ans > mx) {
mx = ans;
ansik = v;
}
}
cout << mx << endl;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
if(ansik[i][j]){
cout<<"+";
}
else cout<<"-";
}
cout<<endl;
}
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll _ = 1;
cin >> _;
while (_--) {
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... |