Submission #330712

# Submission time Handle Problem Language Result Execution time Memory
330712 2020-11-26T10:34:47 Z vitkishloh228 Red-blue table (IZhO19_stones) C++14
0 / 100
2000 ms 764 KB
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
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 = 0; i < n; ++i) {
            for (int j = 0; 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 = 0; i < n; ++i) {
            for (int j = 0; 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
1 Incorrect 0 ms 364 KB Wrong answer in test 1 3: 2 < 3
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 43 ms 364 KB Wrong answer in test 2 50: 49 < 50
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 364 KB Wrong answer in test 1 3: 2 < 3
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2062 ms 764 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2032 ms 596 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 364 KB Wrong answer in test 1 3: 2 < 3
2 Halted 0 ms 0 KB -