Submission #1308745

#TimeUsernameProblemLanguageResultExecution timeMemory
1308745RaresAliens (IOI16_aliens)C++20
Compilation error
0 ms0 KiB
///mai intai n^3
#include <bits/stdc++.h>
#include "aliens.h"
using namespace std;
/**ifstream fin ("date.in");
ofstream fout ("date.out");
#define cin fin
#define cout fout**/


const int MAXN=1e5+10;
typedef long long ll;
ll INF=1e18;

int n,m,k;
ll dp[5010][5010];
vector <pair <int,int>> aux,v;

bool cmp (pair <int,int> a, pair <int,int> b){
    if (a.first==b.first) return a.second>b.second;
    return a.first<b.first;
}

ll take_photos (int N, int M, int K, int r[], int c[]){
    n=N;
    m=M;
    k=K;
    for (int i=0;i<n;++i){
        r[i]++;
        c[i]++;
        if (r[i]>c[i]){
            swap (r[i],c[i]);
        }
        aux.push_back ({r[i],c[i]});
    }

    sort (aux.begin (),aux.end (),cmp);
    v.push_back ({0,0});
    int cmax=0;
    for (auto x:aux){
        if (x.second>cmax){
            cmax=x.second;
            v.push_back (x);
        }
    }

    n=v.size ()-1;

    for (int i=0;i<=n;++i){
        for (int j=0;j<=k;++j){
            dp[i][j]=INF;
        }
    }
    dp[0][0]=0;

    for (int i=1;i<=n;++i){
        for (int j=1;j<=min (i,k);++j){

            for (int t=i-1;t>=0;--t){
                ///daca iau punctele de la i la t
                if (j-1>t) break;
                ll crt=dp[t][j-1];
                crt=crt+1LL*(v[i].second-v[t+1].first+1)*(v[i].second-v[t+1].first+1);
                ll aux=max (0,v[t].second-v[t+1].first+1);
                crt=crt-1LL*aux*aux;
                dp[i][j]=min (dp[i][j],crt);
            }
        }
    }

    ll rez=INF;
    for (int i=1;i<=k;++i){
        rez=min (rez,dp[n][i]);
    }
    return rez;
}

Compilation message (stderr)

aliens.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
aliens_c.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
/usr/bin/ld: /tmp/cc0RIyDJ.o: in function `main':
grader.cpp:(.text.startup+0xff): undefined reference to `take_photos(int, int, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status