Submission #331633

# Submission time Handle Problem Language Result Execution time Memory
331633 2020-11-29T09:39:32 Z Enkhmunkh Red-blue table (IZhO19_stones) C++14
0 / 100
57 ms 1388 KB
#include <bits/stdc++.h>
using namespace std;
int n, m;
void sol() {
    cin >> n >> m;
    if (m == 2) {
        // if (n < m) {
            cout << n << "\n";
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    cout << "+";
                }
                cout << "\n";
            }
        // }
    }else {
        char arr[n][m];
        int tooll[m] = {0};
        int hed = 0;
        if (n % 2 == 0) hed = n/2-1;
        else hed = n/2;
        int mm = m/2+1;
        int niit = m;
        for (int i = 0; i < n; i++) {
            bool k = false;
            if (i % 2 == 0) {
                //zuun
                for (int j = 0, mmm = mm; j < m; j++) {
                    if (mmm > 0 && tooll[j] < hed) {
                        arr[i][j] = '+';
                        tooll[j]++;
                        mmm--;
                    }else {
                        if (mmm == 0 && k == false) {
                            k = true;
                        }
                        arr[i][j] = '-';
                    }
                }
            }else {
                //baruun
                for (int j = m-1, mmm = mm; j >= 0; j--) {
                    if (mmm > 0 && tooll[j] < hed) {
                        arr[i][j] = '+';
                        mmm--;
                        tooll[j]++;
                    }else {
                        if (mmm == 0 && k == false) {
                            k = true;
                        }
                        arr[i][j] = '-';
                    }
                }
            }
            if (k) niit++;
        }
        cout << niit << "\n";
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                cout << arr[i][j];
            }
            cout << "\n";
        }
        cout << "\n";
    }
}
int main () {
    int t;
    cin >> t;
    while (t--) sol();
}
// + + + + + + - - - -
// - - - - + + + + + +
// + + + + - - + + - -
// - - - - - - - - + +
// - - - - - - - - - -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Wrong answer in test 2 1: 1 < 2
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Wrong answer in test 2 1: 1 < 2
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Wrong answer in test 2 1: 1 < 2
# Verdict Execution time Memory Grader output
1 Incorrect 57 ms 1388 KB Wrong answer in test 97 21: 111 < 116
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 43 ms 1388 KB Wrong answer in test 24 24: 43 < 44
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Wrong answer in test 2 1: 1 < 2