This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "paint.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
#define pb push_back
#define ff first
#define ss second
// typedef tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// template< typename T>
// using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll n,m,mid,mn,T,sum,c[1234567],h1,h2,x,y,z,l,r,cnt,cnt1,ans;
vector<ll> vec[1234567];
bool ok[1234567],ok1;
map<ll,ll> mp[1234567];
int minimumInstructions(
int N, int M, int K, std::vector<int> C,
std::vector<int> A, std::vector<std::vector<int>> B) {
for(int i=0;i<M;i++){
for(auto u:B[i]) vec[u].pb(i);
}
for(int i=N-1;i>=0;i--){
for(auto u:vec[C[i]]){
mp[i][u]=1;
//i dah toog u unguur ehlehed segment iin urtiig olno
if(mp[i+1][(u+1)%M]>0 && i < N-1){
mp[i][u]=max(mp[i][u],mp[i+1][(u+1)%M]+1);
}
if(mp[i][u] >= M){
ok[i]=1;
//i r tseg dres ehlej bolno
}
}
}
ll segnum=0;
for(int i=0;i<N;i++)c[i]=-1;
for(int i=0;i<N;i++){
//buh tsegiig ali tsegees ehleh ve gdgig olno
if(ok[i]==1)segnum=i;
c[i]=segnum;
}
/*for(int i=0;i<N;i++){
cout<<c[i]<<" ";
}
cout<<'\n';*/
int i=0;
while(i<N ){
//cout<<i<<" ";
ans++;
x=c[i];
// x ees ehlene
if(x==-1 || x+M-1 <= i){
return -1;
}
i = x+M-1;
// i deer duusna
}
//cout<<'\n';
if(x<n)return -1;
else return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |