답안 #344369

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
344369 2021-01-05T14:44:36 Z koketsu Red-blue table (IZhO19_stones) C++14
100 / 100
72 ms 5328 KB
#include <bits/stdc++.h>
#define pb push_back
#define LL long long
#define Kultivator ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

const LL Mxn = 1e6 + 7;
const LL Mod = 1e9 + 7;
const LL Inf = 1e14 + 7;

int N, M;

int S[1001], A[1001][1001];

void Solve(){
    int Ans = 0;
    bool Inv = false;
    if(M < N){
        swap(M, N);
        Inv = true;
    }
    Ans += M;
    //cout << N << ' ' << M;/
    for(int i = 0; i < M; i++){
        S[i] = -N;
    }
    for(int i = 0; i < N; i++){
        vector <pair <int, int>> V;
        for(int j = 0; j < M; j++){
            A[i][j] = false;
            V.pb({S[j], j});
        }
        sort(V.begin(), V.  end());
        bool Check = false;
        for(int j = 0; j < (M / 2) + 1; j++){
            if(V[j].first + 2 >= 0) Check = true;
        }
        if(!Check){
            Ans++;
            for(int j = 0; j < (M / 2) + 1; j++){
                S[V[j].second] += 2;
                A[i][V[j].second] = true;
            }
        }
    }
    cout << Ans << '\n';
    if(!Inv){
        for(int i = 0; i < N; i++){
            for(int j = 0; j < M; j++){
                if(!A[i][j]) cout << '-';
                else cout << '+';
            }
            cout << '\n';
        }
    } else {
        for(int i = 0; i < M; i++){
            for(int j = 0; j < N; j++){
                if(A[j][i]) cout << '-';
                else cout << '+';
            }
            cout << '\n';
        }
    }
}

int main() {
    Kultivator;
    int tt;
    cin >> tt;
    while(tt--){
        cin >> N >> M;
        Solve();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 2 ms 364 KB Output is correct
4 Correct 3 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 60 ms 1772 KB Output is correct
2 Correct 70 ms 4204 KB Output is correct
3 Correct 66 ms 4204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 61 ms 1900 KB Output is correct
2 Correct 62 ms 4076 KB Output is correct
3 Correct 64 ms 3436 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 2 ms 364 KB Output is correct
4 Correct 3 ms 364 KB Output is correct
5 Correct 60 ms 1772 KB Output is correct
6 Correct 70 ms 4204 KB Output is correct
7 Correct 66 ms 4204 KB Output is correct
8 Correct 61 ms 1900 KB Output is correct
9 Correct 62 ms 4076 KB Output is correct
10 Correct 64 ms 3436 KB Output is correct
11 Correct 15 ms 748 KB Output is correct
12 Correct 52 ms 3308 KB Output is correct
13 Correct 56 ms 3180 KB Output is correct
14 Correct 53 ms 2540 KB Output is correct
15 Correct 72 ms 5328 KB Output is correct
16 Correct 55 ms 4204 KB Output is correct
17 Correct 23 ms 2668 KB Output is correct