이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define endl "\n"
int n, m;
int calc(vector<vector<int>>& a) {
int cur = 0;
for (int i = 0; i < n; ++i) {
int x = 0;
for (int j = 0; j < m; ++j) {
if (a[i][j]) x++;
else x--;
}
if (x > 0) cur++;
}
for (int j = 0; j < m; ++j) {
int x = 0;
for (int i = 0; i < n; ++i) {
if (a[i][j]) x++;
else x--;
}
if (x < 0) cur++;
}
return cur;
}
int main() {
int tt;
cin >> tt;
while (tt--) {
cin >> n >> m;
vector<vector<int>> a(n, vector<int>(m));
int max1 = 0;
for (int i = -1; i < n; ++i) {
for (int j = -1; j < m; ++j) {
a = vector<vector<int>>(n, vector<int>(m));
for (int k = 0; k <= i; ++k) {
for (int z = 0; z <= j; ++z) {
a[k][z] = 1;
}
}
int cur = calc(a);
if (cur > max1) {
max1 = cur;
}
}
}
cout << max1 << endl;
bool ok = false;
for (int i = -1; i < n; ++i) {
if (ok) continue;
for (int j = -1; j < m; ++j) {
a = vector<vector<int>>(n, vector<int>(m));
for (int k = 0; k <= i; ++k) {
for (int z = 0; z <= j; ++z) {
a[k][z] = 1;
}
}
int cur = calc(a);
if (cur == max1 && !ok) {
//max1 = cur;
for (auto elem : a) {
for (auto u : elem) {
if (u) cout << "+";
else cout << "-";
}
cout << endl;
}
cout << endl;
ok = true;
}
}
}
}
}
# | 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... |