Submission #1032296

#TimeUsernameProblemLanguageResultExecution timeMemory
1032296slivajanPainting Walls (APIO20_paint)C++17
51 / 100
218 ms524288 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<vol> tab(M, vol(K, false)); REP(m, 0, M) { FEAC(col, B[m]) tab[m][col] = true; } 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[(y+l)%M][C[x+l - skoc*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...