Submission #386324

#TimeUsernameProblemLanguageResultExecution timeMemory
386324leinad2Painting Walls (APIO20_paint)C++17
0 / 100
1580 ms364 KiB
#include<bits/stdc++.h> using namespace std; vector<vector<int> >B; bool chk(int a, int b) { int s=0, e=B[a].size(); while(s<e) { int m=s+e>>1; if(B[a][m]>=b)e=m; if(B[a][m]<b)s=m+1; } return B[a][s]==b; } int minimumInstructions(int N, int M, int K, vector<int>C, vector<int>A, vector<vector<int> >bB) { B=bB; int i, j, k; vector<int>X;X.resize(N); for(i=0;i<M;i++) { for(j=0;j<=N-M;j++) { int a=0; for(k=0;k<M;k++) { if(!chk((i+k>=M?i+k-M:i+k), C[j+k]))goto w; } X[j]=1; w:; } } i=0; if(X[0]==0||X[N-M]==0)return -1; int ans=0; while(1) { if(i==N-M)return ans+1; k=-1; for(j=i;j<=i+M;j++) { if(X[j])k=j; } if(k==-1)return -1; i=k;ans++; } }

Compilation message (stderr)

paint.cpp: In function 'bool chk(int, int)':
paint.cpp:9:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    9 |         int m=s+e>>1;
      |               ~^~
paint.cpp: In function 'int minimumInstructions(int, int, int, std::vector<int>, std::vector<int>, std::vector<std::vector<int> >)':
paint.cpp:24:17: warning: unused variable 'a' [-Wunused-variable]
   24 |             int a=0;
      |                 ^
#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...