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 double db;
typedef pair<ll,ll> pl;
typedef vector<ll> vl;
#define pb push_back
#define po pop_back
#define ff first
#define ss second
#define MIN -1e18
#define MAX 1e18
#define lw lower_bound
// 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;
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);
}
vector<vector<ll> > mp(M);
for(int i=0;i<N;i++){
for(auto u:vec[C[i]]){
mp[((u-i)%M+M)%M].pb(i);
}
}
vl v(N);
for(auto u:mp){
ll last = N+1;
ll len =0;
for(int i=u.size()-1;i>=0;i--){
if(u[i]+1!=last)len=0;
last++;
v[u[i]]=max(v[u[i]],len);
last=u[i];
}
}
vl ok;
for(int i=0;i<N;i++)if(v[i]>=M)ok.pb(i);
ll Rpoint=0;
ll id=0;
while(Rpoint<N){
while(id<ok.size()&&ok[id]<=Rpoint){
id++;
}
if(id==0)return -1;
ll Lpoint = ok[id-1];
if(Lpoint + M <= Rpoint)return -1;
ans++;
}
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:49:11: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
49 | while(id<ok.size()&&ok[id]<=Rpoint){
| ~~^~~~~~~~~~
# | 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... |