Submission #934347

# Submission time Handle Problem Language Result Execution time Memory
934347 2024-02-27T07:57:16 Z irmuun Painting Walls (APIO20_paint) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
 
using namespace std;
 
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
 
int minimumInstructions(int n,int m,int k,vector<int>C,vector<int>A,vector<vector<int>>B){
    vector<int>pos[k];
    for(int i=0;i<m;i++){
        for(auto x:B[i]){
            pos[x].pb(i);
        }
    }
    vector<int>q(m),q1(m,-1e9);
    vector<int>L(n,-1e9);
    vector<int>change,back;
    for(auto j:pos[C[n-1]]){
        q[j]=1;
        L[n-1]=1;
        change.pb(j);
    }
    for(int i=n-2;i>=0;i--){
        back=change;
        for(auto j:change){
            q1[j]=q[j];
        }
        change.clear();
        for(auto j:pos[C[i]]){
            if(q1[(j+1)%m]==-1e9){
                q[j]=1;
                change.pb(j);
            }
            else{
                q[j]=q1[(j+1)%m]+1;
                change.pb(j);
            }
            L[i]=max(L[i],q[j]);
        }
        for(auto j:back){
            q1[j]=-1e9;
        }
    }
    vector<int>mn(n+1,1e9);
    mn[n]=0;
    multiset<int>st;
    for(int i=n-m+1;i<=n;i++){
        st.insert(mn[i]);
    }
    for(int i=n-m;i>=0;i--){
        bool ok=(L[i]>=m);
        if(ok){
            mn[i]=*st.begin()+1;
        }
        st.erase(st.find(mn[i+m]));
        st.insert(mn[i]);
    }
    if(mn[0]>=1e9) return -1;
    return mn[0];
}

int main(){
    int n,m,k;
    cin>>n>>m>>k;
    vector<int>c(n),a(m);
    vector<vector<int>>b(m);
    for(auto &x:c) cin>>x;
    for(auto &x:a) cin>>x;
    for(int i=0;i<m;i++){
        b[i].resize(a[i]);
        for(auto &x:b[i]){
            cin>>x;
        }
    }
    cout<<minimumInstructions(n,m,k,c,a,b);
}

Compilation message

/usr/bin/ld: /tmp/ccsZieFF.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccTFf3gG.o:paint.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status