Submission #236767

# Submission time Handle Problem Language Result Execution time Memory
236767 2020-06-03T09:10:08 Z VEGAnn Vođe (COCI17_vode) C++14
0 / 120
734 ms 87544 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;
    }

    for (int i = 0; i < n; i++){
        int rt = m - 1;
        int lf = max(0, m - 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;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 1024 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 2048 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 2432 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 3328 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 4736 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 4224 KB Output is correct
2 Incorrect 9 ms 4352 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 102 ms 24184 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 226 ms 42360 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 734 ms 86464 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 720 ms 87544 KB Output isn't correct
2 Halted 0 ms 0 KB -