Submission #957079

#TimeUsernameProblemLanguageResultExecution timeMemory
957079mariaclaraAliens (IOI16_aliens)C++17
25 / 100
2035 ms94548 KiB
#include "aliens.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef tuple<int,int,int> trio; typedef pair<ll,ll> pii; const int MAXN = 2e5+5; const int MOD = 1e9+7; #define sz(x) x.size() #define all(x) x.begin(), x.end() #define mk make_pair #define pb push_back #define f first #define s second ll take_photos(int n, int m, int k, vector<int> r, vector<int> c) { vector<pii> p; for(int i = 0; i < n; i++) p.pb({min(r[i],c[i]), max(r[i],c[i])+1}); sort(all(p), [](pii a, pii b){ if(a.f != b.f) return a.f < b.f; return a.s > b.s; }); vector<pii> square; square.pb({0,0}); for(int i = 0; i < n; i++) if(square.back().s < p[i].s) square.pb(p[i]); ll dp[n+1][k+1]; for(int j = 0; j <= k; j++) dp[0][j] = 0; for(int i = 1; i < sz(square); i++) { dp[i][0] = 1e12; for(int j = 1; j <= k; j++) { dp[i][j] = dp[i][j-1]; for(int l = 1; l <= i; l++) { ll area = dp[l-1][j-1]; area += (square[i].s - square[l].f)*(square[i].s - square[l].f); area -= max(0LL, square[l-1].s - square[l].f)*max(0LL, square[l-1].s - square[l].f); dp[i][j] = min(dp[i][j], area); } } } // intercessao = max(0LL, square[i-1].s - square[i].f)*max(0LL, square[i-1].s - square[i].f); return dp[sz(square)-1][k]; }

Compilation message (stderr)

aliens.cpp: In function 'll take_photos(int, int, int, std::vector<int>, std::vector<int>)':
aliens.cpp:38:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for(int i = 1; i < sz(square); 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...