Submission #1032326

#TimeUsernameProblemLanguageResultExecution timeMemory
1032326slivajanPainting Walls (APIO20_paint)C++17
100 / 100
743 ms23120 KiB
#include "paint.h" #include <bits/stdc++.h> using namespace std; typedef long long un; typedef vector<un> vuc; typedef vector<bool> vol; #define vec vector #define REP(i, a, b) for (un i = (un)a; i < (un)b; i++) #define FEAC(i, a) for (auto&& i : a) constexpr un INF = 1e9; int minimumInstructions(int N, int M, int K, std::vector<int> C, std::vector<int> A, std::vector<std::vector<int>> B) { vec<set<un>> tab(K); REP(m, 0, M) { FEAC(col, B[m]) tab[col].insert(m); } un ret = 0; un x = 0; while (x < N) { un nejkdy = 0; REP(y, 0, M){ bool bad = false; bool skoc = false; un kdy = M; REP(l, 0, M){ if ((x+l - skoc*M < 0) or (x+l - skoc*M >= N) or (not tab[C[x+l - skoc*M]].count((y+l)%M))){ if (not skoc) { kdy = l; l--; skoc = true; } else{ bad = true; break; } } } if(not bad){ nejkdy = max(nejkdy, kdy); } } if (nejkdy == 0){ return -1; } x += nejkdy; ret++; } return ret; }
#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...