Submission #364541

# Submission time Handle Problem Language Result Execution time Memory
364541 2021-02-09T12:42:05 Z mathking1021 Painting Walls (APIO20_paint) C++17
0 / 100
2 ms 2668 KB
#include "paint.h"
#include <vector>
#include <queue>
#define PLL pair<ll, ll>
#define F first
#define S second

using namespace std;

typedef int ll;

ll n, m, k;
vector<vector<ll>> ve;
vector<ll> ve2[100005], c;
bool d[100005];
ll e[100005];
ll x[20005][2005];
priority_queue<PLL, vector<PLL>, greater<PLL> > pq;

int minimumInstructions(
    int N, int M, int K, vector<int> C,
    vector<int> A, vector<vector<int>> B)
{
    n = N;
    m = M;
    k = K;
    ve = B;
    c = C;
    for(ll i = 0; i < ve.size(); i++)
    {
        for(ll j = 0; j < ve[i].size(); j++)
        {
            ve2[ve[i][j]].push_back(i);
        }
    }
    for(ll i = 0; i < c.size(); i++)
    {
        for(ll j = 0; j < ve2[c[i]].size(); j++)
        {
            x[i][ve2[c[i]][j]] = 1;
        }
    }
    for(ll i = 0; i < m; i++)
    {
        ll now = 0;
        for(ll j = 0; j < n; j++)
        {
            if(x[j][(i + j) % m]) now++;
            if(j >= m)if(x[j - m][(i + j) % m]) now--;
            if(now >= m)
            {
                d[j - m] = true;
            }
        }
    }
    if(!d[0]) return -1;
    pq.push(make_pair(1, 0));
    e[0] = 1;
    for(ll i = 1; i <= n - m; i++)
    {
        while(!pq.empty())
        {
            if(pq.top().S < i - m) pq.pop();
            else break;
        }
        if(pq.empty()) return -1;
        ll t1 = pq.top().S;
        ll t2 = pq.top().F;
        if(d[i - 1]) e[i] = t2 + 1, pq.push(make_pair(e[i], i));
        else if(i == n - m) return -1;
    }
    return e[n - m];
}

Compilation message

paint.cpp: In function 'int minimumInstructions(int, int, int, std::vector<int>, std::vector<int>, std::vector<std::vector<int> >)':
paint.cpp:29:21: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for(ll i = 0; i < ve.size(); i++)
      |                   ~~^~~~~~~~~~~
paint.cpp:31:25: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |         for(ll j = 0; j < ve[i].size(); j++)
      |                       ~~^~~~~~~~~~~~~~
paint.cpp:36:21: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for(ll i = 0; i < c.size(); i++)
      |                   ~~^~~~~~~~~~
paint.cpp:38:25: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |         for(ll j = 0; j < ve2[c[i]].size(); j++)
      |                       ~~^~~~~~~~~~~~~~~~~~
paint.cpp:67:12: warning: unused variable 't1' [-Wunused-variable]
   67 |         ll t1 = pq.top().S;
      |            ^~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2668 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2668 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2668 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2668 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2668 KB Output isn't correct
2 Halted 0 ms 0 KB -