제출 #1074375

#제출 시각아이디문제언어결과실행 시간메모리
1074375Joshua_Andersson팀들 (IOI15_teams)C++14
21 / 100
4035 ms222908 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 struct node { node* lc=0, * rc=0; int sum = 0; node(node* lc, node* rc, int s) : lc(lc), rc(rc), sum(s) {} }; node* build(int l, int r) { if (l==r) { return new node(0, 0, 0); } else { int mid = (l + r) / 2; return new node(build(l, mid), build(mid + 1, r), 0); } } node* update(node* x, int l, int r, int i, int s) { if (l==r) { return new node(0, 0, s); } else { int mid = (l + r) / 2; node* ret = new node(x->lc, x->rc, 0); if (i <= mid) ret->lc = update(x->lc, l, mid, i, s); else ret->rc = update(x->rc, mid + 1, r, i, s); if (ret->lc) ret->sum = ret->lc->sum + ret->rc->sum; return ret; } } int query(node* x, int l, int r, int ql, int qr) { if (l > qr || r < ql) return 0; if (l >= ql && r <= qr) return x->sum; int mid = (l + r) / 2; return query(x->lc, l, mid, ql, qr) + query(x->rc, mid + 1, r, ql, qr); } int n; vi a; vi b; typedef pair<double, int> pt; vector<p2> pts; node* roots[int(1e5)]; 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) { return a.second < b.second; }); node* root = build(0, n - 1); rep(i, n) { roots[i] = update(root, 0, n - 1, pts[i].first, 1); } } int rectangle_sum(int xlo, int xhi, int yhi) { int ret = 0; rep(i, 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), min(p.second, yhi)); if (p.first >= xhi) break; prev = p.first; } return rectangle_sum(0, xhi, 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 constructor 'node::node(node*, node*, int)':
teams.cpp:27:23: warning: declaration of 'rc' shadows a member of 'node' [-Wshadow]
   27 |  node(node* lc, node* rc, int s) : lc(lc), rc(rc), sum(s) {}
      |                 ~~~~~~^~
teams.cpp:25:16: note: shadowed declaration is here
   25 |  node* lc=0, * rc=0;
      |                ^~
teams.cpp:27:13: warning: declaration of 'lc' shadows a member of 'node' [-Wshadow]
   27 |  node(node* lc, node* rc, int s) : lc(lc), rc(rc), sum(s) {}
      |       ~~~~~~^~
teams.cpp:25:8: note: shadowed declaration is here
   25 |  node* lc=0, * rc=0;
      |        ^~
teams.cpp: In constructor 'node::node(node*, node*, int)':
teams.cpp:27:23: warning: declaration of 'rc' shadows a member of 'node' [-Wshadow]
   27 |  node(node* lc, node* rc, int s) : lc(lc), rc(rc), sum(s) {}
      |                 ~~~~~~^~
teams.cpp:25:16: note: shadowed declaration is here
   25 |  node* lc=0, * rc=0;
      |                ^~
teams.cpp:27:13: warning: declaration of 'lc' shadows a member of 'node' [-Wshadow]
   27 |  node(node* lc, node* rc, int s) : lc(lc), rc(rc), sum(s) {}
      |       ~~~~~~^~
teams.cpp:25:8: note: shadowed declaration is here
   25 |  node* lc=0, * rc=0;
      |        ^~
teams.cpp: In constructor 'node::node(node*, node*, int)':
teams.cpp:27:23: warning: declaration of 'rc' shadows a member of 'node' [-Wshadow]
   27 |  node(node* lc, node* rc, int s) : lc(lc), rc(rc), sum(s) {}
      |                 ~~~~~~^~
teams.cpp:25:16: note: shadowed declaration is here
   25 |  node* lc=0, * rc=0;
      |                ^~
teams.cpp:27:13: warning: declaration of 'lc' shadows a member of 'node' [-Wshadow]
   27 |  node(node* lc, node* rc, int s) : lc(lc), rc(rc), sum(s) {}
      |       ~~~~~~^~
teams.cpp:25:8: note: shadowed declaration is here
   25 |  node* lc=0, * rc=0;
      |        ^~
teams.cpp: In lambda function:
teams.cpp:87:29: warning: declaration of 'b' shadows a global declaration [-Wshadow]
   87 |  sort(all(pts), [](p2 a, p2 b)
      |                          ~~~^
teams.cpp:70:4: note: shadowed declaration is here
   70 | vi b;
      |    ^
teams.cpp:87:23: warning: declaration of 'a' shadows a global declaration [-Wshadow]
   87 |  sort(all(pts), [](p2 a, p2 b)
      |                    ~~~^
teams.cpp:69:4: note: shadowed declaration is here
   69 | vi a;
      |    ^
teams.cpp: In function 'int sum(std::vector<std::pair<int, int> >&, int, int, int)':
teams.cpp:113:40: warning: unused parameter 'ylo' [-Wunused-parameter]
  113 | int sum(vector<p2>& hull, int xhi, int ylo, int yhi)
      |                                    ~~~~^~~
teams.cpp: In function 'bool dominates(p2, p2)':
teams.cpp:127:25: warning: declaration of 'b' shadows a global declaration [-Wshadow]
  127 | bool dominates(p2 a, p2 b)
      |                      ~~~^
teams.cpp:70:4: note: shadowed declaration is here
   70 | vi b;
      |    ^
teams.cpp:127:19: warning: declaration of 'a' shadows a global declaration [-Wshadow]
  127 | bool dominates(p2 a, p2 b)
      |                ~~~^
teams.cpp:69:4: note: shadowed declaration is here
   69 | 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...