Submission #424141

# Submission time Handle Problem Language Result Execution time Memory
424141 2021-06-11T17:13:41 Z doowey Red-blue table (IZhO19_stones) C++14
54 / 100
53 ms 2116 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int N = 1010;


vector<vector<char>> get(int n, int m, int &sol){
    vector<vector<char>> sos;
    sos.resize(n);
    for(int i = 0 ; i < n; i ++ ){
        for(int j = 0 ; j < m ; j ++ ){
            sos[i].push_back('-');
        }
    }
    for(int i = 0 ; i < n; i ++ ){
        for(int j = 0; j < (m + 2) / 2; j ++ ){
            sos[i][j] = '+';
        }
    }
    int mod = (n+2)/2;
    int xx = 0;
    for(int take = 0 ; take < (m-3)/2; take ++ ){
        xx = take;
        for(int j = 0; j < mod; j ++ ){
            sos[j][take] = '-';
            sos[j][xx + (m+1)/2] = '+';
            xx ++ ;
            xx %= m/2;
        }
    }
    sol = 0;
    int cnt;
    for(int i = 0 ; i < n; i ++ ){
        cnt = 0;
        for(int j = 0 ; j < m ; j ++ ){
            if(sos[i][j] == '+'){
                cnt ++ ;
            }
        }
        if(cnt >= (m + 2) / 2){
            sol ++ ;
        }
    }
    for(int j = 0 ; j < m ; j ++ ){
        cnt = 0;
        for(int i = 0 ; i < n; i ++ ){
            if(sos[i][j] == '-'){
                cnt ++ ;
            }
        }
        if(cnt >= (n + 2) / 2){
            sol ++ ;
        }
    }
    return sos;
}

void solve(){
    int n, m;
    cin >> n >> m;
    if(n >= m){
        int res = 0;
        vector<vector<char>> cc = get(n, m, res);
        cout << res << "\n";
        for(auto x : cc){
            for(auto y : x){
                cout << y;
            }
            cout << "\n";
        }
    }
    else{
        int res = 0;
        vector<vector<char>> cc = get(m, n, res);
        cout << res << "\n";
        for(int i = 0 ; i < n; i ++ ){
            for(int j = 0 ; j < m ; j ++ ){
                if(cc[j][i] == '-'){
                    cc[j][i] = '+';
                }
                else{
                    cc[j][i] = '-';
                }
                cout << cc[j][i];
            }
            cout << "\n";
        }

    }
}

int main(){
    fastIO;
    //freopen("in.txt","r",stdin);
    int tc;
    cin >> tc;
    for(int iq = 1; iq <= tc; iq ++ ){
        solve();
    }
    return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
4 Correct 4 ms 388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 53 ms 1260 KB Output is correct
2 Correct 43 ms 1836 KB Output is correct
3 Correct 39 ms 2116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 45 ms 1348 KB Wrong answer in test 24 24: 34 < 44
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
4 Correct 4 ms 388 KB Output is correct
5 Correct 53 ms 1260 KB Output is correct
6 Correct 43 ms 1836 KB Output is correct
7 Correct 39 ms 2116 KB Output is correct
8 Incorrect 45 ms 1348 KB Wrong answer in test 24 24: 34 < 44
9 Halted 0 ms 0 KB -