제출 #1074336

#제출 시각아이디문제언어결과실행 시간메모리
1074336Joshua_Andersson팀들 (IOI15_teams)C++14
0 / 100
4094 ms20204 KiB
#include "teams.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; const ll linf = ll(1e18); typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> p2; #define rep(i, high) for (int i = 0; i < high; i++) #define repp(i, low, high) for (int i = low; i < high; i++) #define repe(i, container) for (auto& i : container) #define sz(container) ((int)container.size()) #define all(x) begin(x),end(x) #if _LOCAL #define assert(x) if (!(x)) __debugbreak() #endif int n; vi a; vi b; typedef pair<double, int> pt; vector<p2> pts; void init(int N, int A[], int B[]) { n = N; a.resize(N); b.resize(N); rep(i, N) a[i] = A[i], b[i] = B[i]; rep(i, n) { pts.emplace_back(a[i], b[i]); } sort(all(pts), [](p2 a, p2 b) { if (a.second!=b.second) return a.second < b.second; return a.first < b.first; }); } int rectangle_sum(int xlo, int xhi, int ylo, int yhi) { int ret = 0; repp(i, ylo, yhi+1) { ret += pts[i].first >= xlo && pts[i].first <= xhi; } return ret; } typedef tuple<int, int, int> p3; int sum(vector<p2>& hull, int xhi, int ylo, int yhi) { int prev = -1; int taken = 0; repe(p, hull) { taken += rectangle_sum(prev + 1, min(p.first, xhi), 0, p.second); if (p.first >= xhi) break; prev = p.first; } return rectangle_sum(0, xhi, 0, yhi)-taken; } bool dominates(p2 a, p2 b) { return a.first >= b.first && a.second >= b.second; } const int inf = int(2e9); int can(int m, int K[]) { //cout << rectangle_sum(1, 3, 1, 3); vi k(m); rep(i, m) k[i] = K[i]; sort(all(k)); vector<p2> taken_hull; auto insert = [&](p2 new_corner) { bool good = 1; repe(p, taken_hull) if (dominates(p, new_corner)) good = 0; if (good) { auto it = taken_hull.begin(); while (it != taken_hull.end()) { if (dominates(new_corner, *it)) { it = taken_hull.erase(it); } else it = next(it); } taken_hull.push_back(new_corner); } sort(all(taken_hull)); }; int lo = 0; rep(i, m) { while (lo < sz(pts) && pts[lo].second < k[i]) { insert(p2(inf, lo)); lo++; } if (sum(taken_hull, k[i], 0, n-1)<k[i]) { return 0; } int lob = lo-1; int hib = n; while (lob+1<hib) { int mid = (lob + hib) / 2; if (sum(taken_hull, k[i], lo, mid) < k[i]) { lob = mid; } else hib = mid; } p2 new_corner = p2(k[i], hib); insert(new_corner); } return 1; }

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

teams.cpp: In lambda function:
teams.cpp:40:29: warning: declaration of 'b' shadows a global declaration [-Wshadow]
   40 |  sort(all(pts), [](p2 a, p2 b)
      |                          ~~~^
teams.cpp:25:4: note: shadowed declaration is here
   25 | vi b;
      |    ^
teams.cpp:40:23: warning: declaration of 'a' shadows a global declaration [-Wshadow]
   40 |  sort(all(pts), [](p2 a, p2 b)
      |                    ~~~^
teams.cpp:24:4: note: shadowed declaration is here
   24 | vi a;
      |    ^
teams.cpp: In function 'int sum(std::vector<std::pair<int, int> >&, int, int, int)':
teams.cpp:60:40: warning: unused parameter 'ylo' [-Wunused-parameter]
   60 | int sum(vector<p2>& hull, int xhi, int ylo, int yhi)
      |                                    ~~~~^~~
teams.cpp: In function 'bool dominates(p2, p2)':
teams.cpp:74:25: warning: declaration of 'b' shadows a global declaration [-Wshadow]
   74 | bool dominates(p2 a, p2 b)
      |                      ~~~^
teams.cpp:25:4: note: shadowed declaration is here
   25 | vi b;
      |    ^
teams.cpp:74:19: warning: declaration of 'a' shadows a global declaration [-Wshadow]
   74 | bool dominates(p2 a, p2 b)
      |                ~~~^
teams.cpp:24:4: note: shadowed declaration is here
   24 | vi a;
      |    ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...