Submission #559723

# Submission time Handle Problem Language Result Execution time Memory
559723 2022-05-10T13:10:31 Z ala2 Painting Walls (APIO20_paint) C++14
0 / 100
1 ms 212 KB
#include "paint.h"
#include <vector>
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
using namespace std;
map<pair<int,int>,int>mp;
int a[1001000];
vector<int>v;
int n,m;
map<int,int>mm;
int good(int i,int j)
{
    for(int k=0; k<m; k++)
    {
        int x=(i+k)%(m);
        int y=j+k;
        if( mp[ {x,a[y]}]==0 )
        {
            //
            // cout<<"    :   "<<x<<"  "<<a[y]<<"  "<<y<<endl;
            return 0;
        }
    }
    return 1;
}
int minimumInstructions(int N, int M, int K, vector<int> C,vector<int> A, vector<vector<int>> B)
{

    n=N;
    m=M;
    for(int i=0; i<C.size(); i++)
    {
        a[i]=C[i];
    }
    for(int i=0; i<B.size(); i++)
    {
        for(int j=0; j<B[i].size(); j++)
        {
            mp[ {i,B[i][j]}]=1;
            //   cout<<"          "<<i+1<<"    "<<B[i][j]<<endl;
        }
    }
    int x=n-m;
    for(int i=0; i<m; i++)
    {
        for(int j=0; j<=x; j++)
        {
            if(good(i,j))
            {
                if(!mm[j])
                v.pb(j),mm[j]=1;
                // cout<<"        "<<j<<endl;
            }
        }
    }
    sort(v.begin(),v.end());
    int cur=0;
    int ans=1;
    int bb=0;
    if(v.size()==0)
    {
        return -1;
    }
    if(v[0]!=0)
    {
        return -1;
    }
    for(int i=1; i<v.size(); i++)
    {
        if(v[i]-v[i-1]>m)
            return -1;
    }

 //   if(n==m)
 //   {
 //       return 1;
 //   }
    for(int i=1; i<v.size(); i++)
    {

        if(i==v.size()-1)
        {
            if(v[i]==x)
            {
                ans++;
                break;
            }
            else
            {
                bb=1;
                break;
            }
        }
        if(v[i]-cur>m)
            bb=1;
        if(v[i+1]-cur>m)
        {
            ans++;
            cur=v[i];
        }
    }
    if(bb)
        return -1;
    return ans;
}

Compilation message

paint.cpp: In function 'int minimumInstructions(int, int, int, std::vector<int>, std::vector<int>, std::vector<std::vector<int> >)':
paint.cpp:33:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     for(int i=0; i<C.size(); i++)
      |                  ~^~~~~~~~~
paint.cpp:37:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     for(int i=0; i<B.size(); i++)
      |                  ~^~~~~~~~~
paint.cpp:39:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |         for(int j=0; j<B[i].size(); j++)
      |                      ~^~~~~~~~~~~~
paint.cpp:70:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |     for(int i=1; i<v.size(); i++)
      |                  ~^~~~~~~~~
paint.cpp:80:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   80 |     for(int i=1; i<v.size(); i++)
      |                  ~^~~~~~~~~
paint.cpp:83:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   83 |         if(i==v.size()-1)
      |            ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -