Submission #619278

#TimeUsernameProblemLanguageResultExecution timeMemory
619278Dremix10Aliens (IOI16_aliens)C++17
12 / 100
311 ms489448 KiB
#include "aliens.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pi; typedef pair<ll,ll> pl; #define endl '\n' #define all(x) (x).begin(),(x).end() #define F first #define S second #ifdef dremix #define p(x) cerr<<#x<<" = "<<x<<endl; #define p2(x,y) cerr<<#x<<" , "<<#y<<" = "<<x<<" , "<<y<<endl; #define pp(x) cerr<<#x<<" = "<<x.F<<"-"<<x.S<<endl; #define pv(x) cerr<<#x<<" = {";for(auto v : x)cerr<<v<<", ";cerr<<"}"<<endl; #define ppv(x) cerr<<#x<<" = {";for(auto v : x)cerr<<v.F<<"-"<<v.S<<", ";cerr<<"}"<<endl; #else #define p(x) {} #define p2(x,y) {} #define pp(x) {} #define pv(x) {} #define ppv(x) {} #endif const int N = 1005; const int MOD = 1e9+7; const ll INF = 1e18+5; struct ano{ int x,y,id; }; bool cmp(ano a, ano b){ return min(a.x,a.y) > min(b.x,b.y); } bool v[N][N]; void clean(vector<ano> &a){ while(!a.empty() && v[a.back().x][a.back().y]) a.pop_back(); } void print(vector<ano> &arr){ return; for(auto x : arr){ cerr<<x.x<<" "<<x.y<<" "<<x.id<<endl; } } long long take_photos(int n, int m, int K, std::vector<int> r, std::vector<int> c) { int i,j,k; //vector<ano> arr(n); set<pi> s; for(i=0;i<n;i++){ s.insert({r[i],c[i]}); } vector<int> arr; n = s.size(); for(auto x : s) arr.push_back(x.F); //bool v[m][m] = {}; int dp[n][n][K]; //memset(dp,MOD,sizeof(dp)); for(i=0;i<n;i++)for(j=0;j<=i;j++)for(k=0;k<K;k++){ //cerr<<dp[i][j][k]<<" "; dp[i][j][k] = MOD; } dp[0][0][K-1] = 1; int pref[n+1]; int curr,nxt,net; pv(arr) for(i=0;i<n-1;i++)for(j=0;j<=i;j++){ curr = (arr[i]-arr[j]+1)*(arr[i]-arr[j]+1); nxt = (arr[i+1]-arr[j]+1)*(arr[i+1]-arr[j]+1); net = nxt - curr; for(k=0;k<K;k++){ if(k > 0) dp[i+1][i+1][k-1] = min(dp[i+1][i+1][k-1],dp[i][j][k] + 1); dp[i+1][j][k] = min(dp[i+1][j][k],dp[i][j][k]+net); } } int ans = MOD; for(j=0;j<n;j++) for(i=0;i<K;i++) ans = min(ans,dp[n-1][j][i]); return ans; }

Compilation message (stderr)

aliens.cpp: In function 'long long int take_photos(int, int, int, std::vector<int>, std::vector<int>)':
aliens.cpp:75:9: warning: unused variable 'pref' [-Wunused-variable]
   75 |     int pref[n+1];
      |         ^~~~
#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...