Submission #1021999

#TimeUsernameProblemLanguageResultExecution timeMemory
1021999vjudge1Aliens (IOI16_aliens)C++17
0 / 100
1 ms2396 KiB
#include <bits/stdc++.h> #define ent '\n' typedef long long ll; using namespace std; const int maxn = 1e5+12; ll dp[1005][505]; int l[maxn]; long long take_photos(int n, int m, int k, vector<int> r, vector<int> c){ for(int i=1;i<=m;i++){ l[i] = i+1; } for(int i=0;i<n;i++){ if(r[i] < c[i]){ swap(r[i], c[i]); } l[r[i]+1] = min(l[r[i]+1], c[i]+1); } for(int i=1;i<=m;i++){ for(int j=0;j<=k;j++){ dp[i][j] = 1e12; } } for(int i=1;i<=m;i++){ if(l[i] > i){ continue; } int mn = 1e9; for(int j=i;j>=1;j--){ if(l[j] >= mn) continue; mn = min(mn, l[j]); for(int t=1;t<=k;t++){ ll val = dp[j-1][t-1] + (i - mn + 1) * 1ll * (i - mn + 1); if(mn <= j-1) val -= (j - mn) * 1ll * (j - mn); dp[i][t] = min(dp[i][t], val); } } } for(int i=m;i>=0;i--){ if(dp[i][k] < 1e12){ return dp[i][k]; } } }

Compilation message (stderr)

aliens.cpp: In function 'long long int take_photos(int, int, int, std::vector<int>, std::vector<int>)':
aliens.cpp:46:1: warning: control reaches end of non-void function [-Wreturn-type]
   46 | }
      | ^
#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...