Submission #308757

# Submission time Handle Problem Language Result Execution time Memory
308757 2020-10-01T21:07:05 Z nikatamliani Red-blue table (IZhO19_stones) C++14
0 / 100
2000 ms 40292 KB
#include <bits/stdc++.h>
using namespace std;
int main() {
    int T = 1;
    cin >> T;
    while(T--) {
        int n, m, cntI = 0, best = 0;
        cin >> n >> m; 
        char ans[n + 1][m + 1];
        memset(ans, 0, sizeof ans);
        for(int i = 0; i <= n; ++i) {
            int sum = i * ((m + 1) / 2);
            int cnt_less = m - sum % m;
            int cnt_more = sum % m;
            int less = sum / n;
            int more = less + 1; 
            int rem = n * m - sum, now = i;
            while(true) {
                bool done = false;
                if(cnt_less > 0 && rem >= less) {
                    rem -= less;
                    --cnt_less;
                    done = true;
                } else {
                    if(cnt_more > 0 && rem >= more) {
                        rem -= more;
                        --cnt_more;
                        done = true;
                    } 
                }
                if(!done) break;
                ++now;
            }
            if(best < now) {
                best = now, cntI = i;
            }
        }
        int prev = 1;
        for(int i = 1; i <= cntI; ++i) {
            int cnt = (m + 1) / 2;
            for(int j = prev; cnt--; j = (j == m ? 1 : j + 1)) {
                prev = j + 1;
                ans[i][j] = '+';
            }
        }
        for(int i = 1; i <= n; ++i) {
            for(int j = 1; j <= m; ++j) {
                if(ans[i][j] != '+') {
                    cout << '-';
                } else {
                    cout << '+';
                }
            }
            cout << '\n';
        }
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB Expected integer, but "---" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB Expected integer, but "---" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2083 ms 40292 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB Expected integer, but "---" found
2 Halted 0 ms 0 KB -