Submission #555696

#TimeUsernameProblemLanguageResultExecution timeMemory
555696fuad27Aliens (IOI16_aliens)C++17
16 / 100
159 ms2264 KiB
#include "aliens.h" #include<bits/stdc++.h> using namespace std; const long long INF = 1e18; long long take_photos(int n, int m, int k, std::vector<int> r, std::vector<int> c) { if(c==r) { for(int i = 0;i<n;i++) { if(c[i] < r[i]) { swap(c[i], r[i]); } } vector<pair<int,int>> pts; for(int i = 0;i<n;i++) { pts.push_back({c[i], r[i]}); } sort(pts.begin(), pts.end()); long long dp[n+1][k+1]; dp[0][0] = 0; for(int i = 1;i<=n;i++) { dp[i][0] = INF; } for(int i = 0;i<=k;i++)dp[0][i] = 0; for(int i = 1;i<=n;i++) { for(int j = 1;j<=k;j++) { int mx = 0; dp[i][j] = INF; for(int z = i;z>=1;z--) { mx = max(mx, pts[i-1].first-pts[z-1].second+1); dp[i][j] = min(dp[i][j], dp[z-1][j-1] + mx*mx); } } } return dp[n][k]; } else { for(int i = 0;i<n;i++) { if(c[i] < r[i]) { swap(c[i], r[i]); } } vector<vector<bool>> v(m, vector<bool> (m, 0)); for(int i = 0;i<n;i++) { for(int f = min(r[i], c[i]);f<=max(r[i], c[i]);f++) { for(int j = min(r[i], c[i]);j<=max(r[i], c[i]);j++) { v[f][j] = 1; } } } long long ans = 0; for(int i = 0;i<m;i++) { for(int j = 0;j<m;j++) { if(v[i][j]) { ans++; } } } return ans; } }
#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...