Submission #599362

#TimeUsernameProblemLanguageResultExecution timeMemory
599362gromperenAliens (IOI16_aliens)C++14
0 / 100
1 ms212 KiB
#include <bits/stdc++.h> #include "aliens.h" const int INF = 1e9+7; using namespace std; long long take_photos(int n, int m, int k, vector<int> r, vector<int> c) { /* vector<vector<int>> vis(m+1, vector<int>(m+1)); int ans = 0; for (int i = 0; i < n; ++i) { for (int x = r[i]; x <= c[i]; ++x) { for (int y = r[i]; y <= c[i]; ++y) { if (vis[x][y]) continue; ans++; vis[x][y] = 1; } } } */ vector<pair<int,int>> tmpcords; vector<pair<int,int>> cords; for (int i = 0; i < n; ++i) { tmpcords.push_back({r[i], c[i]}); } sort(tmpcords.begin(), tmpcords.end()); for (int i = 0; i < n; ++i) { if (i > 0 && tmpcords[i].first == cords[i-1].first && tmpcords[i].second == cords[i-1].second) continue; cords.push_back(tmpcords[i]); } vector<vector<int>> dp(n+1, vector<int>(k+1, INF)); n = cords.size(); dp[0][0] = 0; //for (int i = 0; i < cords.size(); ++i) { //dp[0][i] = 0; //} for (int i = 1; i <= cords.size(); ++i) { for (int j =1; j <= k; ++j) { for (int p = 0; p < i; ++p) { dp[i][j] = min(dp[i][j], dp[p][j-1] + (cords[i-1].first - cords[p].first + 1) * (cords[i-1].second - cords[p].first + 1)); } } } return dp[cords.size()][k]; }

Compilation message (stderr)

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