Submission #567340

# Submission time Handle Problem Language Result Execution time Memory
567340 2022-05-23T10:42:17 Z Stickfish Painting Walls (APIO20_paint) C++17
0 / 100
0 ms 212 KB
#include "paint.h"
#include <vector>
#include <bitset>
using namespace std;

const int MAXN = 501;
const int MAXM = 201;
bitset<MAXM> goodseg[MAXN];
bitset<MAXM> rgoodcl[MAXN];

bool get_good_seg(int n, int m, int k, vector<int>& cl, vector<vector<int>>& goodcl, int l) {
    if (l > n - m)
        return false;
    return goodseg[l].count();
}

int minimumInstructions(int n, int m, int k, vector<int> cl, vector<int> a, vector<vector<int>> goodcl) {
    for (int i = 0; i < n; ++i) {
        --cl[i];
        for (int j = 0; j < m; ++j)
            goodseg[i][j] = 1;
    }
    for (int i = 0; i < m; ++i) {
        for (auto ccl : goodcl[i])
            rgoodcl[ccl][i] = 1;
    }
    for (int i = 0; i < n; ++i) {
        bitset<MAXM> curgoodcl = rgoodcl[cl[i]];
        for (int j = i; j >= 0 && j > i - m; --j) {
            goodseg[j] &= curgoodcl;
            curgoodcl = curgoodcl << 1;
            curgoodcl[0] = curgoodcl[m];
            curgoodcl[m] = 0;
        }
    }
    
    int endcvr = 0;
    int maxcvr = 0;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (get_good_seg(n, m, k, cl, goodcl, i))
            maxcvr = i + m;
        if (i >= endcvr) {
            endcvr = maxcvr;
            ++ans;
        }
        if (i >= endcvr)
            return -1;
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -