Submission #159647

# Submission time Handle Problem Language Result Execution time Memory
159647 2019-10-23T17:17:28 Z Dima_Borchuk Red-blue table (IZhO19_stones) C++17
0 / 100
100 ms 1420 KB
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int q , n , m;
    cin >> q;

    while(q--){
        cin >> n >> m;
        int ans = m , k;
        vector<pair<int , int>> v(m + 1);
        int line[n + 1] = {0};
        char a[n + 5][m + 5];

        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= m; j++){
                a[i][j] = '-';
            }
        }

        for(int i = 1; i <= m; i++){
            v[i].second = i;
        }

        int l = 1;

        while(l <= n){
            sort(v.begin() + 1 , v.end());
            for(int r = 1; r <= m; r++){
                if(v[r].first < n / 2 && line[l] <= m / 2){
                    a[l][v[r].second] = '+';
                    v[r].first++;
                    line[l]++;
                }
            }
            l++;
        }

        for(int i = 1; i <= n; i++){
            k = 0;
            for(int j = 1; j <= n; j++){
                if(a[i][j] == '+') k++;
            }
            if(k > m / 2) ans++;
        }

        cout << ans << endl;

        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= m; j++){
                cout << a[i][j];
            }
            cout << endl;
        }
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB in the table A+B is not equal to 2
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 376 KB in the table A+B is not equal to 45
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB in the table A+B is not equal to 2
# Verdict Execution time Memory Grader output
1 Incorrect 100 ms 1420 KB Wrong answer in test 97 21: 112 < 116
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 73 ms 1316 KB in the table A+B is not equal to 46
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB in the table A+B is not equal to 2