이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |