Submission #436197

#TimeUsernameProblemLanguageResultExecution timeMemory
436197aymane7Painting Walls (APIO20_paint)C++17
0 / 100
1 ms204 KiB
#include<bits/stdc++.h> //#include "paint.h" #pragma GCC optimize("O2") #define deb(x) cout << #x << " = " << x <<endl #define F first #define S second #define PB push_back #define MP make_pair #define all(c) c.begin(), c.end() #define endl "\n" #define sz(u) (int)(u.size()) #define L(x)(2*x) #define R(x)(2*x+1) #define M(x,y)((x+y)/2) typedef long long ll; typedef unsigned long long ull; using namespace std; int minimumInstructions(int n,int m,int k,vector<int> c,vector<int> a,vector<vector<int>> b){ vector<int> mp(k,-1); //mp[i] = position of constructor who like the i th color for(int i=0;i<m;i++) if(a[i]>0) mp[b[i][0]]=i; int ans=0,cur=-1; //cur moves in constructors array for(int i=0;i<n;i++){ if(mp[c[i]]==-1) return -1; if(cur==-1) ans++,cur=mp[c[i]]; else{ if(m==1){ ans++; continue; } cur=(cur+1)%m; if(a[cur]>0 && b[cur][0]==c[i]) continue; ans++; cur=mp[c[i]]; } } return ans; } /* int main(){ } */
#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...