답안 #236753

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
236753 2020-06-03T08:16:03 Z VEGAnn Vođe (COCI17_vode) C++14
72 / 120
3000 ms 43632 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 = int(2e9);
const ll OO = 1e18;
const int md = int(1e9) + 7;
int mem[N][N], net[N], tp[N], n, m, k;

int get(int ps, int vl){
    if (mem[ps][vl] > 0) return mem[ps][vl] - 1;

    if (vl == m - 1) return 0;

    int res = 0;

    if (tp[net[ps]] == tp[ps]){
        for (int nw = min(vl + k, m - 1); nw > vl && res == 0; nw--)
            if (get(net[ps], nw) == 1)
                res = 1;
    } else {
        for (int nw = min(vl + k, m - 1); nw > vl && res == 0; nw--)
            if (get(net[ps], nw) == 0)
                res = 1;
    }

    mem[ps][vl] = res + 1;

    return res;
}

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];
        net[i] = (i + 1) % n;
    }

    for (int i = 0; i < n; i++){
        int ans = 0;

        ans = get(i, 0);

        cout << (tp[i] ^ ans ^ 1) << " ";
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 640 KB Output is correct
3 Correct 5 ms 640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 1408 KB Output is correct
2 Correct 5 ms 896 KB Output is correct
3 Correct 9 ms 1280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 1536 KB Output is correct
2 Correct 6 ms 1408 KB Output is correct
3 Correct 7 ms 1536 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 2176 KB Output is correct
2 Correct 14 ms 2432 KB Output is correct
3 Correct 9 ms 2304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 3072 KB Output is correct
2 Correct 16 ms 2944 KB Output is correct
3 Correct 6 ms 2304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 2688 KB Output is correct
2 Correct 19 ms 2816 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 177 ms 19320 KB Output is correct
2 Correct 688 ms 20760 KB Output is correct
3 Execution timed out 3080 ms 36936 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Correct 1190 ms 38376 KB Output is correct
2 Execution timed out 3085 ms 43632 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3101 ms 29944 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3099 ms 39416 KB Time limit exceeded
2 Halted 0 ms 0 KB -