Submission #135901

#TimeUsernameProblemLanguageResultExecution timeMemory
135901ckodserAliens (IOI16_aliens)C++14
25 / 100
276 ms3832 KiB
#include "aliens.h" #include <algorithm> #include <bitset> #include <complex> #include <deque> #include <exception> #include <fstream> #include <functional> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <iterator> #include <limits> #include <list> #include <locale> #include <map> #include <memory> #include <new> #include <numeric> #include <ostream> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdexcept> #include <streambuf> #include <string> #include <typeinfo> #include <utility> #include <valarray> #include <vector> #if __cplusplus >= 201103L #include <array> #include <atomic> #include <chrono> #include <condition_variable> #include <forward_list> #include <future> #include <initializer_list> #include <mutex> #include <random> #include <ratio> #include <regex> #include <scoped_allocator> #include <system_error> #include <thread> #include <tuple> #include <typeindex> #include <type_traits> #include <unordered_map> #include <unordered_set> #endif #define ll int #define pb push_back #define mp make_pair #define ld long double #define F first #define S second #define pii pair<ll,ll> using namespace :: std; const ll maxn=4100; const ll maxk=4010; const ll inf=1e9+900; ll tav2(ll x){ return x*x; } ll dp[maxn][maxk]; vector<pii> vec; ll mx[maxn]; ll cost(ll u,ll i){ return tav2(vec[i].F-vec[u+1].S+1)-tav2(max(0,vec[u].F-vec[u+1].S+1)); } long long take_photos(int n, int m, int k, vector<int> r, vector<int> c) { swap(n,m); fill(mx,mx+maxn,inf); for(ll i=0;i<m;i++){ if(c[i]>r[i]){ swap(c[i],r[i]); } mx[r[i]]=min(mx[r[i]],(ll)c[i]); } stack<ll> stk; for(ll i=0;i<n;i++){ while(stk.size() && mx[stk.top()]>=mx[i]){ stk.pop(); } if(mx[i]!=inf){ stk.push(i); } } while(stk.size()){ vec.pb(mp(stk.top(),mx[stk.top()])); stk.pop(); } sort(vec.begin(),vec.end()); for(ll i=0;i<vec.size();i++){ dp[i][0]=inf; pii e=vec[i]; for(ll j=1;j<=k;j++){ dp[i][j]=tav2(vec[i].F-vec[0].S+1); for(ll u=0;u<i;u++){ dp[i][j]=min(dp[i][j],dp[u][j-1]+cost(u,i)); } } } return dp[vec.size()-1][k]; }

Compilation message (stderr)

aliens.cpp: In function 'long long int take_photos(int, int, int, std::vector<int>, std::vector<int>)':
aliens.cpp:107:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(ll i=0;i<vec.size();i++){
             ~^~~~~~~~~~~
aliens.cpp:109:7: warning: variable 'e' set but not used [-Wunused-but-set-variable]
   pii e=vec[i];
       ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...