Submission #949308

#TimeUsernameProblemLanguageResultExecution timeMemory
949308vjudge1Painting Walls (APIO20_paint)C++17
63 / 100
1503 ms13756 KiB
#include "paint.h" #include <bits/stdc++.h> #define ll int #define str string #define ins insert #define ld long double #define pb push_back #define pf push_front #define pof pop_front() #define pob pop_back() #define lb lower_bound #define ub upper_bound #define endl "\n" #define fr first #define sc second #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define sz size() #define vll vector<ll> #define bc back() #define arr array #define pll vector<pair<ll,ll>> using namespace std; template<class S,class T> bool chmin(S &a,const T &b) { return a>b?(a=b)==b:false; } template<class S,class T> bool chmax(S &a,const T &b) { return a<b?(a=b)==b:false; } int minimumInstructions(int n, int m, int k, vll c, vll a, vector<vll> b) { vector<vll> v(k); ll i,j; for(i=0;i<m;i++){ for(j=0;j<a[i];j++){ v[b[i][j]].pb(i); } } ll l=0,ans=0; map<ll,ll> mp; while(l<n){ if(mp[l] || l<0) return -1; mp[l]++; if(l+m-1>=n) {l--;continue;} vll vv,nv; for(auto i : v[c[l]])vv.pb(i); for(i=l+1;i<=l+m-1;i++){ if(vv.sz==0)break; ll x=0,y=0; if(vv.bc==m-1 && v[c[i]].sz && v[c[i]][0]==0)nv.pb(0); while(x<vv.sz && y<v[c[i]].sz){ if(vv[x]+1>v[c[i]][y])y++; else if(vv[x]+1<v[c[i]][y])x++; else{ nv.pb(v[c[i]][y]); x++; y++; } } vv=nv; nv.clear(); } if(vv.sz) {ans++;l+=m;} else l--; } return ans; }

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:52:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |             while(x<vv.sz && y<v[c[i]].sz){
      |                    ^
paint.cpp:52:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |             while(x<vv.sz && y<v[c[i]].sz){
      |                               ^
#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...