제출 #957074

#제출 시각아이디문제언어결과실행 시간메모리
957074mariaclaraAliens (IOI16_aliens)C++17
4 / 100
1 ms500 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])-1, max(r[i],c[i])}); 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; for(int i = 0; i < n; i++) if(square.empty() or square.back().s < p[i].s) square.pb(p[i]); ll ans = 0; for(int i = 0; i < sz(square); i++) { ans += (square[i].s - square[i].f)*(square[i].s - square[i].f); if(i == 0) continue; ans -= max(0LL, square[i-1].s - square[i].f)*max(0LL, square[i-1].s - square[i].f); } while(sz(square) > k) { ll min_qtd = 1e12, ind = 0; for(int i = 1; i < sz(square); i++) { ll area = (square[i].s - square[i-1].f)*(square[i].s - square[i-1].f); area -= (square[i].s - square[i].f)*(square[i].s - square[i].f); area -= (square[i-1].s - square[i-1].f)*(square[i-1].s - square[i-1].f); area += max(0LL, square[i-1].s - square[i].f)*max(0LL, square[i-1].s - square[i].f); if(area < min_qtd) min_qtd = area, ind = i; } ans += min_qtd; square[ind-1].s = square[ind].s; square.erase(square.begin()+ind); } return ans; }

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

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