이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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]=1;
//i r tseg dres ehlej bolno
}
}
}
ll segnum=0;
for(int i=1;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+1];
// x ees ehlene
if(x==-1 || x+M-1 <= i){
return -1;
}
i = x+M-1;
// i deer duusna
}
//cout<<'\n';
if(i!=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... |