제출 #776238

#제출 시각아이디문제언어결과실행 시간메모리
776238farukAliens (IOI16_aliens)C++17
25 / 100
2033 ms22356 KiB
#include "aliens.h" #include <bits/stdc++.h> #define intsum(a) (a.second - a.first + 1LL) * (a.second - a.first + 1LL) #define all(a) a.begin(), a.end() using namespace std; typedef long long ll; typedef pair<ll, ll> pii; const ll INF = 1e18; bool cmp(pii a, pii b) {return pii(a.first, -a.second) < pii(b.first, -b.second);} vector<pii> get_intervals(vector<int> r, vector<int> c) { vector<pii> all_intervals; for (int i = 0; i < r.size(); i++) all_intervals.push_back({min(r[i], c[i]), max(r[i], c[i])}); sort(all(all_intervals), cmp); vector<pii> intervals; for (pii a : all_intervals) { if (intervals.size() == 0) { intervals.push_back(a); } else { pii last = *prev(intervals.end()); if (last.second < a.second) intervals.push_back(a); } } return intervals; } long long take_photos(int n, int m, int k, std::vector<int> r, std::vector<int> c) { vector<pii> ints = get_intervals(r, c); ints.insert(ints.begin(), pii(-1, -1)); vector<vector<ll> > dp(k + 1, vector<ll>(ints.size() + 1, INF)); dp[0][0] = 0; for (int i = 1; i <= k; i++) { dp[i][0] = 0; for (int j = 1; j < ints.size(); j++) { dp[i][j] = dp[i - 1][j]; for (int l = 1; l <= j; l++) { ll cost = dp[i - 1][l - 1]; cost += intsum(pii(ints[l].first, ints[j].second)); pii intersection_interval(ints[l].first, ints[l - 1].second); if (intersection_interval.first <= intersection_interval.second) cost -= intsum(intersection_interval); dp[i][j] = min(dp[i][j], cost); } } } return dp[k][ints.size() - 1]; }

컴파일 시 표준 에러 (stderr) 메시지

aliens.cpp: In function 'std::vector<std::pair<long long int, long long int> > get_intervals(std::vector<int>, std::vector<int>)':
aliens.cpp:17:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for (int i = 0; i < r.size(); i++)
      |                     ~~^~~~~~~~~~
aliens.cpp: In function 'long long int take_photos(int, int, int, std::vector<int>, std::vector<int>)':
aliens.cpp:42:27: 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]
   42 |         for (int j = 1; j < ints.size(); j++) {
      |                         ~~^~~~~~~~~~~~~
#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...