Submission #982684

#TimeUsernameProblemLanguageResultExecution timeMemory
982684stegatxins0Painting Walls (APIO20_paint)C++17
0 / 100
1 ms1368 KiB
#include <bits/stdc++.h> #include "paint.h" using namespace std; #ifdef DEBUG #include "debug.cpp" #else #define dbg(...) #define dbgarr(...) #endif // const int mxM = 50001; // int f[mxM]; // const int mxN = 1e5+1; int mp[mxN], ok[mxN]; int minimumInstructions( int N, int M, int K, std::vector<int> C, std::vector<int> A, std::vector<std::vector<int>> B) { memset(mp,0,sizeof(mp)); memset(ok,0,sizeof(ok)); // since each contarctor can only like one color, if no of contractor less than no of color, // if(M < N)return -1; // NOTE: B might have color not in C deque<int> q; int curunq = 0; for(int i=0; i<N; i++){ if(i >= M){ mp[C[i - M]]--; if(mp[C[i - M]] == 0){ curunq--; } q.pop_back(); } q.push_front(C[i]); mp[C[i]]++; if(mp[C[i]] <= 1){ curunq++; } if(curunq == M)ok[i] = 1; } dbgarr(ok,N); if(!ok[M-1] || !ok[N-1])return -1; int jump = 1; int p = M-1, tojump; while(p < N-1){ tojump = -1; for(int i=min(p+M,N-1); i>=p+1; i--){ if(ok[i]){ tojump = i; break; } } if(tojump == -1)return -1; jump++; p = tojump; // dbg(p, p+M); } return jump; }
#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...