Submission #293371

# Submission time Handle Problem Language Result Execution time Memory
293371 2020-09-08T01:02:08 Z daniel920712 Painting Walls (APIO20_paint) C++14
0 / 100
4 ms 4992 KB
#include "paint.h"

#include <vector>
#include <stdio.h>
#include <queue>
using namespace std;
bool can[2005][100005]={0};
bool use[2005][100005]={0};
int r[2005][100005];
int rr[100005];
bool have[200005]={0};
int DP[200005];
vector < int > all;
vector < int > how[200005];
int N,M;
queue < pair < int , int > > now;
int minimumInstructions(int N, int M, int K, vector<int> C, vector<int> A,vector< vector<int> > B)
{
    int i,j,ok;
    all=C;
    ::N=N;
    ::M=M;
    for(i=0;i<M;i++)
    {
        for(j=0;j<A[i];j++)
        {
            can[i][B[i][j]]=1;
            how[B[i][j]].push_back(i);
        }
    }
    for(i=N;i>=0;i--)
    {
        rr[i]=-1e9;
        for(j=M-1;j>=0;j--)
        {
            if(i==N) r[j][i]=N;
            else if(can[j][all[i]]==0) r[j][i]=-1e9;
            else r[j][i]=max(i,r[(j+1)%M][i+1]);
            rr[i]=max(rr[i],r[j][i]);
        }

    }

    if(N<=200&&M<=500)
    {
        now.push(make_pair(0,N));
        for(i=N-1;i>=0;i--)
        {
            ok=0;
            DP[i]=1e9;
            while(!now.empty()&&now.front().second-i>M) now.pop();
            if(i+M>N) continue;
            else
            {
                if(rr[i]>=i+M-1)
                {
                    if(now.empty()) DP[i]=1e9;
                    else
                    {
                        DP[i]=now.front().first+1;
                        now.push(make_pair(DP[i],i));
                    }
                }
            }
        }
    }


    int t=DP[0];
    if(t>=1000000000) return -1;
    return t;
}

Compilation message

paint.cpp: In function 'int minimumInstructions(int, int, int, std::vector<int>, std::vector<int>, std::vector<std::vector<int> >)':
paint.cpp:19:13: warning: variable 'ok' set but not used [-Wunused-but-set-variable]
   19 |     int i,j,ok;
      |             ^~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4992 KB Output is correct
2 Correct 3 ms 4992 KB Output is correct
3 Correct 3 ms 4992 KB Output is correct
4 Correct 4 ms 4992 KB Output is correct
5 Correct 4 ms 4992 KB Output is correct
6 Correct 3 ms 4992 KB Output is correct
7 Incorrect 4 ms 4992 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4992 KB Output is correct
2 Correct 4 ms 4992 KB Output is correct
3 Correct 3 ms 4992 KB Output is correct
4 Correct 3 ms 4992 KB Output is correct
5 Correct 3 ms 4992 KB Output is correct
6 Correct 4 ms 4992 KB Output is correct
7 Correct 4 ms 4992 KB Output is correct
8 Correct 3 ms 4992 KB Output is correct
9 Incorrect 4 ms 4992 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4992 KB Output is correct
2 Correct 4 ms 4992 KB Output is correct
3 Correct 3 ms 4992 KB Output is correct
4 Correct 3 ms 4992 KB Output is correct
5 Correct 3 ms 4992 KB Output is correct
6 Correct 4 ms 4992 KB Output is correct
7 Correct 4 ms 4992 KB Output is correct
8 Correct 3 ms 4992 KB Output is correct
9 Incorrect 4 ms 4992 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4992 KB Output is correct
2 Correct 4 ms 4992 KB Output is correct
3 Correct 3 ms 4992 KB Output is correct
4 Correct 3 ms 4992 KB Output is correct
5 Correct 3 ms 4992 KB Output is correct
6 Correct 4 ms 4992 KB Output is correct
7 Correct 4 ms 4992 KB Output is correct
8 Correct 3 ms 4992 KB Output is correct
9 Incorrect 4 ms 4992 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4992 KB Output is correct
2 Correct 4 ms 4992 KB Output is correct
3 Correct 3 ms 4992 KB Output is correct
4 Correct 3 ms 4992 KB Output is correct
5 Correct 3 ms 4992 KB Output is correct
6 Correct 4 ms 4992 KB Output is correct
7 Correct 4 ms 4992 KB Output is correct
8 Correct 3 ms 4992 KB Output is correct
9 Incorrect 4 ms 4992 KB Output isn't correct
10 Halted 0 ms 0 KB -