Submission #597365

#TimeUsernameProblemLanguageResultExecution timeMemory
597365OzyPainting Walls (APIO20_paint)C++17
0 / 100
655 ms524288 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 100000 #define MK 1000 lli n,m,k,res,pos,mejor,dif,a,last,b,otro,ult; //valores de 0 a m lli dp[MAX+2][1002]; lli top[MAX+2]; //checar memoria vector<lli> colores[MAX+2]; 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) { colores[B[i][j]].push_back(i); } } rep(i,0,colores[C[n-1]].size()-1) dp[n-1][i] = 1; top[n-1] = 1; repa(i,n-2,0) { top[i] = 0; a = 0; b = 0; for(auto act : colores[C[i]]) { while (b < (colores[C[i+1]].size()-1) && colores[C[i+1]][b] < (act+1)) b++; if (colores[C[i+1]][b] == (act+1)) dp[i][a] = dp[i+1][b] + 1; else dp[i][a] = 1; if (dp[i][a] > m) dp[i][a] = m; top[i] = max(top[i], dp[i][a]); a++; } //caso especial de overlaping ult = colores[ C[i] ].size() - 1; if (colores[C[i]][ ult ] == m-1 && colores[C[i+1]][0] == 0) { dp[i][ult] = dp[i+1][0] + 1; if(dp[i][ult] > m) dp[i][ult] = m; top[i] = max(top[i], dp[i][ult]); } } 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; }

Compilation message (stderr)

paint.cpp: In function 'int minimumInstructions(int, int, int, std::vector<int>, std::vector<int>, std::vector<std::vector<int> >)':
paint.cpp:5:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 | #define rep(i,a,b) for (int i = (a); i <= (b); i++)
      |                                        ^
paint.cpp:31:5: note: in expansion of macro 'rep'
   31 |     rep(i,0,colores[C[n-1]].size()-1) dp[n-1][i] = 1;
      |     ^~~
paint.cpp:39:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |             while (b < (colores[C[i+1]].size()-1) && colores[C[i+1]][b] < (act+1)) b++;
      |                    ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...