Submission #395180

#TimeUsernameProblemLanguageResultExecution timeMemory
395180syl123456Painting Walls (APIO20_paint)C++17
0 / 100
1 ms300 KiB
#include "paint.h" #include <bits/stdc++.h> using namespace std; int minimumInstructions( int N, int M, int K, std::vector<int> C, std::vector<int> A, std::vector<std::vector<int>> B) { vector<vector<int>> mp(K); for (int i = 0; i < M; ++i) for (int j : B[i]) mp[j].push_back(i); for (int i : C) if (mp[i].empty()) return -1; int cnt = 0; set<pair<int, int>> ops; for (int i = 0; i < N; ++i) { int x = (i - mp[C[i]].back()) % M; if (x < 0) x += M; auto it = ops.lower_bound({x, 0}); while (it != ops.end() && it->second <= i - M) ops.erase(it), it = ops.lower_bound({x, 0}); if (it == ops.end() || it->first != x) ops.emplace(x, i), ++cnt; } return cnt; }
#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...