Submission #597351

#TimeUsernameProblemLanguageResultExecution timeMemory
597351OzyPainting Walls (APIO20_paint)C++17
51 / 100
659 ms184076 KiB
#include "paint.h" #include<bits/stdc++.h> using namespace std; #define lli int #define rep(i,a,b) for (int i = (a); i <= (b); i++) #define repa(i,a,b) for (int i = (a); i >= (b); i--) #define debug(a) cout << #a << " = " << a << endl #define debugsl(a) cout << #a << " = " << a << ", " #define MAX 20000 #define MK 100000 lli n,m,k,res,pos,mejor,dif,a,last; //valores de 0 a m lli lejos[MAX+2][2002]; bitset<MK> tabla[2002]; lli top[MAX+2]; //checar memoria int minimumInstructions(int N, int M, int K, std::vector<int> C,std::vector<int> A, std::vector<std::vector<int>> B) { n = N; m = M; k = K; rep(i,0,m-1) { rep(j,0,A[i]-1) { tabla[i][B[i][j]] = 1; } } rep(j,0,m-1) lejos[n][j] = 0; repa(i,n-1,0) { top[i] = 0; rep(j,0,m-1) { if (tabla[j][C[i]] == 1) { lejos[i][j] = lejos[i+1][(j+1)%m] + 1; if (lejos[i][j] > m) lejos[i][j] = m; top[i] = max(top[i], lejos[i][j]); } else lejos[i][j] = 0; } } if (top[0] < m) return -1; pos = m; last = 0; res = 1; rep(i,1,n-1) { if (top[i] == m) last = i; if (i == pos) { pos = last + m; res++; } } if (pos < n) return -1; else return res; }
#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...