Submission #1360354

#TimeUsernameProblemLanguageResultExecution timeMemory
1360354xorshift벽 칠하기 (APIO20_paint)C++20
0 / 100
0 ms344 KiB
#include <bits/stdc++.h>
using namespace std;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
using pint = pair<int, int>;
using vpint = vector<pint>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using pill = pair<int, ll>;
using vpill = vector<pill>;
using plli = pair<ll, int>;
using vplli = vector<plli>;
#define fi first
#define se second
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n)-1; i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a)-1; i >= (b); --i)

int minimumInstructions(int N, int M, int K, vint C, vint A, vector<vint> B) {
    vector<vint> f(K);
    rep(i, M) rep(j, A[i]) f[B[i][j]].push_back(i);
    vint idx;
    rep(y, N-M+1) {
        rep(x, M) {
            bool works = true;
            rep(i, M) {
                int pos = y+(x+i)%M;
                auto it = find(all(B[i]), C[pos]);
                if (it == B[i].end()) works = false;
            }
            if (works) {
                idx.push_back(y); break;
            }
        }
    }
    int res = 0;
    int cv = 0;
    for(int i = 0; i < sz(idx);) {
        int j = i;
        while (j+1 < sz(idx) && idx[j+1] <= cv) j++;
        if (idx[j] > cv) return -1;
        cv = idx[j]+M;
        i = j+1;
        res++;
    }
    return res;
}
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...