답안 #338676

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
338676 2020-12-23T16:17:28 Z yungBaSe Red-blue table (IZhO19_stones) C++14
27 / 100
36 ms 1388 KB
// quit the talkin', cut the check!
#include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define nptr nullptr

using namespace std;

const int MAXN = 2e4 + 1;
const ll MOD = 1e9 + 7;
const int INF = 2e9;
const ll INFLL = 1e18;
const ld PI = acos(-1);

void solve() {
    int n, m;
    cin >> n >> m;
    char a[n][m];
    if(n > m){
        for(int i = 0; i < m; ++i){
            for(int j = 0; j < n; ++j){
                if(i >= 1 + !(m & 1) && ((i - (1 + !(m & 1))) % 2 == 0 && j <= n / 2)){
                    a[j][i] = '-';
                }
                else a[j][i] = '+';
            }
        }
    }
    else{
        for(int i = 0; i < n; ++i){
            for(int j = 0; j < m; ++j){
                if(i >= 1 + !(n & 1) && ((i - (1 + !(n & 1))) % 2 == 0 && j <= m / 2)){
                    a[i][j] = '+';
                }
                else a[i][j] = '-';
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < n; ++i){
        int sum = 0;
        for(int j = 0; j < m; ++j){
            sum += bool(a[i][j] == '+');
        }
        ans += bool(sum > m / 2);
    }
    for(int j = 0; j < m; ++j){
        int sum = 0;
        for(int i = 0; i < n; ++i){
            sum += bool(a[i][j] == '-');
        }
        ans += bool(sum > n / 2);
    }
    cout << ans << '\n';
    for(int i = 0; i < n; ++i, cout << '\n'){
        for(int j = 0; j < m; ++j){
            cout << a[i][j];
        }
    }
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("brokeday.in","r",stdin);
    //freopen("richday.out","w",stdout);
    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 2 ms 364 KB Wrong answer in test 5 29: 31 < 32
# 결과 실행 시간 메모리 Grader output
1 Incorrect 36 ms 1388 KB Wrong answer in test 97 21: 107 < 116
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 35 ms 1388 KB Wrong answer in test 24 24: 35 < 44
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 2 ms 364 KB Wrong answer in test 5 29: 31 < 32