Submission #487029

# Submission time Handle Problem Language Result Execution time Memory
487029 2021-11-13T20:14:36 Z SirCovidThe19th Red-blue table (IZhO19_stones) C++17
0 / 100
43 ms 1348 KB
#include <bits/stdc++.h>
using namespace std;

void solve(){
    int n, m, flip = 0; cin >> n >> m; 
    if (n < m) swap(n, m), flip = 1;
    int ans[n + 1][m + 1] = {}, rowFill[m] = {}, tot = n + m;

    for (int j = 1, i = 1; j <= m; j++){
        int cnt = 0;
        while (cnt < n - (n / 2 + 1)){
            ans[i][j] = 1; rowFill[i]++;
            i++; cnt++; if (i > n) i = 1;
        }
    }
    for (int j = 1; j <= m; j++){
        int badCol = 0;
        for (int i = 1; i <= n; i++)
            if (rowFill[i] < m / 2 + 1 and !ans[i][j]){
                ans[i][j] = 1; rowFill[i]++;
                badCol = 1;
            }
        tot -= badCol;
    }
    cout<<tot<<endl;
    if (flip) swap(n, m);
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++){
            int cur = !flip ? ans[i][j] : !ans[j][i];
            cout<<(cur ? "+" : "-")<<(j == m ? "\n" : "");
        }
}

int main(){
    int tc; cin >> tc;
    while (tc--) solve();
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 288 KB in the table A+B is not equal to 3
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 288 KB in the table A+B is not equal to 46
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 288 KB in the table A+B is not equal to 3
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 43 ms 1304 KB in the table A+B is not equal to 105
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 43 ms 1348 KB in the table A+B is not equal to 88
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 288 KB in the table A+B is not equal to 3
2 Halted 0 ms 0 KB -