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<bits/stdc++.h>
using namespace std;
vector<vector<int> >B;
bool chk(int a, int b)
{
int s=0, e=B[a].size();
while(s<e)
{
int m=s+e>>1;
if(B[a][m]>=b)e=m;
if(B[a][m]<b)s=m+1;
}
return B[a][s]==b;
}
int minimumInstructions(int N, int M, int K, vector<int>C, vector<int>A, vector<vector<int> >bB)
{
B=bB;
int i, j, k;
vector<int>X;X.resize(N);
for(i=0;i<M;i++)
{
for(j=0;j<=N-M;j++)
{
int a=0;
for(k=0;k<M;k++)
{
a+=chk((i+k>=M?i+k-M:i+k), C[j+k]);
}
if(a==M)X[j]=1;
}
}
i=0;
if(X[0]==0||X[N-M]==0)return -1;
int ans=0;
while(1)
{
if(i==N-M)return ans+1;
k=-1;
for(j=i+1;j<=i+M;j++)
{
if(X[j])k=j;
}
if(k==-1)return -1;
i=k;ans++;
}
}
Compilation message (stderr)
paint.cpp: In function 'bool chk(int, int)':
paint.cpp:9:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
9 | int m=s+e>>1;
| ~^~
# | 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... |