Submission #364602

# Submission time Handle Problem Language Result Execution time Memory
364602 2021-02-09T13:53:13 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;
ll lt[100005];
ll d[100005];
ll e[100005];
bool v[100005];
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++)
        {
            ll t = ve2[c[i]][j];
            if(lt[(t - i % m + m) % m] + 1 == i) d[(t - i % m + m) % m]++;
            else d[(t - i % m + m) % m] = 1;
            lt[(t - i % m + m) % m] = i;
            if(d[(t - i % m + m) % m] >= m) v[i] = true;
        }
    }
    if(!v[m]) return -1;
    pq.push(make_pair(1, m));
    e[m] = 1;
    for(ll i = m + 1; i < n; i++)
    {
        while(!pq.empty())
        {
            if(pq.top().S < i) pq.pop();
            else break;
        }
        if(pq.empty()) return -1;
        ll t1 = pq.top().S;
        ll t2 = pq.top().F;
        if(v[i]) e[i] = t2 + 1, pq.push(make_pair(e[i], i));
        else if(i == n - 1) return -1;
    }
    return e[n - 1];
}

Compilation message

paint.cpp: In function 'int minimumInstructions(int, int, int, std::vector<int>, std::vector<int>, std::vector<std::vector<int> >)':
paint.cpp:30: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]
   30 |     for(ll i = 0; i < ve.size(); i++)
      |                   ~~^~~~~~~~~~~
paint.cpp:32:25: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |         for(ll j = 0; j < ve[i].size(); j++)
      |                       ~~^~~~~~~~~~~~~~
paint.cpp:37:21: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     for(ll i = 0; i < c.size(); i++)
      |                   ~~^~~~~~~~~~
paint.cpp:39:25: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |         for(ll j = 0; j < ve2[c[i]].size(); j++)
      |                       ~~^~~~~~~~~~~~~~~~~~
paint.cpp:59:12: warning: unused variable 't1' [-Wunused-variable]
   59 |         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 -