Submission #330834

# Submission time Handle Problem Language Result Execution time Memory
330834 2020-11-26T17:23:05 Z vitkishloh228 Red-blue table (IZhO19_stones) C++14
0 / 100
50 ms 1516 KB
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
    int tt;
    cin >> tt;
    while (tt--) {
        int n, m;
        cin >> n >> m;
        if (n == 1) {
            cout << m << '\n';
            for (int i = 0; i < n; ++i) {
                cout << "+\n";
            }
            continue;
        }
        if (m == 1) {
            cout << n << '\n';
            for (int i = 0; i < m; ++i) {
                cout << "-";
            }
            cout << '\n';
            continue;
        }
        cout << (n + m - 2 - (1 - n % 2) - (1 - m % 2)) << '\n';
        int l;
        if (m % 2 == 0) l = (m + 2) / 2;
        else l = (m + 1) / 2;
        int it = 0;
        vector<vector<int>> ans(n, vector<int>(m));
        vector<int> cnt(m);
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < l; ++j) {
                ans[i][it] = 1;
                cnt[it]++;
                it = (it + 1) % m;
            }
            int max1 = 0;
            for (int j = 0; j < m; ++j) {
                max1 = max(max1, cnt[j]);
            }
            if (n % 2 == 0) {
                if (max1 >= (n - 1) / 2) break;
            }
            else if (max1 >= n / 2) break;
        }
        for (auto e : ans) {
            for (auto u : e) {
                if (u) cout << "+";
                else cout << "-";
            }
            cout << '\n';
        }
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 364 KB Wrong answer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 364 KB Wrong answer
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 364 KB Wrong answer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 48 ms 1388 KB in the table A+B is not equal to 116
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 50 ms 1516 KB in the table A+B is not equal to 44
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 364 KB Wrong answer
2 Halted 0 ms 0 KB -