Submission #965709

#TimeUsernameProblemLanguageResultExecution timeMemory
965709PringPainting Walls (APIO20_paint)C++17
0 / 100
1 ms444 KiB
#include <bits/stdc++.h> #include "paint.h" using namespace std; #ifdef MIKU string dbmc = "\033[1;38;2;57;197;187m", dbrs = "\033[0m"; #define debug(x...) cout << dbmc << "[" << #x << "]: ", dout(x) void dout() { cout << dbrs << endl; } template <typename T, typename ...U> void dout(T t, U ...u) { cout << t << (sizeof...(u) ? ", " : ""); dout(u...); } #else #define debug(...) 39 #endif #define fs first #define sc second #define mp make_pair #define FOR(i, j, k) for (int i = j, Z = k; i < Z; i++) using ll = long long; typedef pair<int, int> pii; namespace { const int MXN = 200005, INF = 1e9; int n, m, k; vector<int> c; vector<vector<int>> clr; int cid[MXN], worker[MXN]; bitset<MXN> b; int miku() { fill(cid, cid + k, -1); FOR(i, 0, m) { assert(clr[i].size() == 1); cid[clr[i][0]] = i; } FOR(i, 0, n) { if (cid[c[i]] == -1) return -1; worker[i] = cid[c[i]]; } FOR(i, 1, n) if ((worker[i - 1] + 1) % m == worker[i]) b[i - 1] = true; // FOR(i, 0, n) cout << worker[i] << ' '; // cout << endl; // FOR(i, 0, n) cout << cid[i] << ' '; // cout << endl; int ans = 0; for (int i = 0, j = 0; i < n; i = ++j) { while (b[j]) j++; // debug(i, j); int x = j - i + 1; if (x < m) return -1; ans += (x - 1) / m + 1; } return ans; } } int minimumInstructions(int N, int M, int K, vector<int> C, vector<int> A, vector<vector<int>> B) { ::n = N; ::m = M; ::k = K; ::c = C; ::clr = B; return miku(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...