Submission #924679

#TimeUsernameProblemLanguageResultExecution timeMemory
924679DzadzoWiring (IOI17_wiring)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "wiring.h" #define ll long long #define int ll #define pb push_back #define S second #define F first #define pii pair<int,int> #define vi vector <int> #define vvi vector <vi> #define vvvi vector <vvi> #define vp vector <pii> #define vvp vector <vp> #define vb vector <bool> #define vvb vector <vb>; #define INF LLONG_MAX #define MOD 1000000007 #define MAXN 100000 using namespace std; long long min_total_length(std::vector<int> r, std::vector<int> b){ vp v; v.pb({0,0}); for (int x:r)v.pb({x,-1}); for (int x:b)v.pb({x,1}); int n=v.size()-1; sort(v.begin()+1,v.end()); vi dp(n+1,INF),p(n+1); dp[0]=0; for (int i=1;i<=n;i++){ p[i]=p[i-1]+v[i].F; } int cur=1,prev=0; while (v[prev].S==v[prev+1].S)cur++; int ind; for (int i=cur+1;i<=n;i++){ if (v[i].S!=v[i-1].S){ ind=v[i-1].F; for (int j=i-cur;j<i;j++)if (dp[j-1]!=INF)dp[j]=min(dp[j],dp[j-1]+v[i].F-v[j].F); prev=cur; cur=0; } cur++; if (dp[i-1]!=INF) dp[i]=min(dp[i],dp[i-1]+v[i].F-ind); if (cur<=prev && dp[i-2*cur]!=INF)dp[i]=min(dp[i],dp[i-2*cur]+p[i]+p[i-2*cur]-2*p[i-cur]); } return dp[n]; }

Compilation message (stderr)

wiring.cpp: In function 'long long int min_total_length(std::vector<long long int>, std::vector<long long int>)':
wiring.cpp:44:33: warning: 'ind' may be used uninitialized in this function [-Wmaybe-uninitialized]
   44 |   dp[i]=min(dp[i],dp[i-1]+v[i].F-ind);
/usr/bin/ld: /tmp/cccBQ4TB.o: in function `main':
grader.cpp:(.text.startup+0x23a): undefined reference to `min_total_length(std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status