Submission #1311357

#TimeUsernameProblemLanguageResultExecution timeMemory
1311357hackjsPainting Walls (APIO20_paint)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

#define int long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define str string
#define sz(a) (int) a.size()
#define pii pair<int,int>
#define vi vector<int>
#define rall(a) a.rbegin(), a.rend()
#define all(a) a.begin(), a.end()
#define mp(a,b) make_pair(a,b)
#define fi first
#define se second
#define debug(a) cout << #a << " = " << a << endl;
#define fff cout << "----------------------------------------" <<endl;
// #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
using namespace std;
// using namespace __gnu_pbds;

mt19937 rng(47);
int randint(int l, int r){
    return uniform_int_distribution<int>(l, r)(rng);
}

int minimumInstructions(int n,int m,int k, vi& c, vi& a, vector<vi>& b){
    vector<unordered_map<int,int>> DP(n);
    vi F(n, 0);
    vector<vi> val(k);
    vector<unordered_map<int,bool>> vv(k);
    for(int i = 0;i < m;++i){
        for(int j : b[i]){
            val[j].pb(i);
            vv[j][i] = true;
        }
    }
    for(int j : val[c[n-1]]) {
        DP[n-1][j] = 1;
    }
    for(int i = n-2;i >= 0;--i){
        int x = 0;
        for(int j : val[c[i+1]]){
            int th = (j - 1 + m) % m;
            if(vv[c[i]][th]){
                x = max(x, DP[i][th] = max(DP[i][th], DP[i+1][j] + 1));
            }
        }
        for(int j : val[c[i]]){
            x = max(x, DP[i][j] = max(DP[i][j], 1ll));
        }
        F[i] = x;
    }
    int ans = 0;
    int l = 0;
    while(l < n){
        int x =F[l];
        x = min(x, m);
        ++ans;
        l += x;
        if(x == 0){
            return -1;
        }
    }
    return ans;
}

Compilation message (stderr)

/usr/bin/ld: /tmp/ccPQK0O7.o: in function `main':
grader.cpp:(.text.startup+0x278): undefined reference to `minimumInstructions(int, int, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >)'
collect2: error: ld returned 1 exit status