# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
386324 | leinad2 | Painting Walls (APIO20_paint) | C++17 | 1580 ms | 364 KiB |
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++)
{
if(!chk((i+k>=M?i+k-M:i+k), C[j+k]))goto w;
}
X[j]=1;
w:;
}
}
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;j<=i+M;j++)
{
if(X[j])k=j;
}
if(k==-1)return -1;
i=k;ans++;
}
}
Compilation message (stderr)
# | 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... |