답안 #236769

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
236769 2020-06-03T09:13:58 Z VEGAnn Vođe (COCI17_vode) C++14
120 / 120
697 ms 94416 KB
#include <bits/stdc++.h>
#define sz(x) ((int)x.size())
#define ft first
#define sd second
using namespace std;
typedef long long ll;
const int N = 5010;
const int oo = 2e9;
const ll OO = 1e18;
const int md = int(1e9) + 7;
short tp[N], pre[N], net[N], vl[2][N], ad[2][N][N], n, m, k;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);

#ifdef _LOCAL
    freopen("in.txt","r",stdin);
#endif // _LOCAL

    cin >> n >> m >> k;

    k = min(m, k);

    for (int i = 0; i < n; i++) {
        cin >> tp[i];
        pre[i] = (i - 1 + n) % n;
        net[i] = (i + 1) % n;
    }

    if (m == 1){
        for (int i = 0; i < n; i++)
            cout << (tp[i] ^ 1) << " ";
        return 0;
    }

    for (int i = 0; i < n; i++){
        int rt = m - 2;
        int lf = max(0, m - 1 - k);

        ad[0][pre[i]][rt]++;
        if (lf > 0)
            ad[0][pre[i]][lf - 1]--;
    }

    for (int j = m - 2; j >= 0; j--){
        for (int i = 0; i < n; i++){
            vl[0][i] += ad[0][i][j];
            vl[1][i] += ad[1][i][j];

            int typ = 0;

            if (tp[net[i]] == tp[i]){
                if (vl[1][i] > 0)
                    typ = 1;
            } else {
                if (vl[0][i] > 0)
                    typ = 1;
            }

            if (j == 0)
                cout << (tp[i] ^ 1 ^ typ) << " ";
            else {
                int rt = j - 1;
                int lf = max(0, j - k);

                ad[typ][pre[i]][rt]++;

                if (lf > 0)
                    ad[typ][pre[i]][lf - 1]--;
            }
        }
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 1024 KB Output is correct
3 Correct 5 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 2048 KB Output is correct
2 Correct 5 ms 1280 KB Output is correct
3 Correct 6 ms 2048 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 2432 KB Output is correct
2 Correct 6 ms 2304 KB Output is correct
3 Correct 6 ms 2432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 3328 KB Output is correct
2 Correct 8 ms 3840 KB Output is correct
3 Correct 8 ms 3712 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 4736 KB Output is correct
2 Correct 9 ms 4480 KB Output is correct
3 Correct 9 ms 4096 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 4224 KB Output is correct
2 Correct 9 ms 4404 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 93 ms 24184 KB Output is correct
2 Correct 109 ms 25208 KB Output is correct
3 Correct 620 ms 85752 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 204 ms 42360 KB Output is correct
2 Correct 570 ms 84728 KB Output is correct
3 Correct 219 ms 49656 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 697 ms 86268 KB Output is correct
2 Correct 11 ms 2304 KB Output is correct
3 Correct 8 ms 1408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 691 ms 87384 KB Output is correct
2 Correct 587 ms 94416 KB Output is correct
3 Correct 589 ms 68216 KB Output is correct