제출 #276635

#제출 시각아이디문제언어결과실행 시간메모리
276635Haunted_Cpp자리 배치 (IOI18_seats)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; int H, W; vector<int> R, C; int LO = 0; int HI = 0; struct Node { int R_min, R_max; int C_min, C_max; Node() { R_min = C_min = INF; R_max = C_max = -INF; } void merge(Node l, Node r) { R_min = min(l.R_min, r.R_min); C_min = min(l.C_min, r.C_min); R_max = max(l.R_max, r.R_max); C_max = max(l.C_max, r.C_max); } }; struct SegmentTree { vector<Node> seg; SegmentTree() { seg.resize(4 * R.size()); build(LO, HI - 1, 0, R, C); } void build(int l, int r, int node) { if (l == r) { seg[node].R_min = seg[node].R_max = R[l]; seg[node].C_min = seg[node].C_max = C[l]; return; } int mid = l + (r - l) / 2; build(l, mid, 2 * node + 1, R, C); build(mid + 1, r, 2 * node + 2, R, C); seg[node].merge(seg[2 * node + 1], seg[2 * node + 2]); } void modify(int l, int r, int node, int delta, int where, bool which) { if (l == r) { if (which) { seg[node].R_max = seg[node].R_min = delta; } else { seg[node].C_max = seg[node].C_min = delta; } return; } int mid = l + (r - l) / 2; if (where <= mid) { modify(l, mid, 2 * node + 1, delta, where, which); } if (where >= mid + 1) { modify(mid + 1, r, 2 * node + 2, delta, where, which); } seg[node].merge(seg[2 * node + 1], seg[2 * node + 2]); } Node query(int ql, int qr, int l, int r, int node) { if (l >= ql && r <= qr) return seg[node]; int mid = (l + r) >> 1; Node esq; if (ql <= mid) { esq = query(ql, qr, l, mid, 2 * node + 1); } Node dir; if (qr >= mid + 1) { dir = query(ql, qr, mid + 1, r, 2 * node + 2); } Node ans; ans.merge(esq, dir); return ans; } }; SegmentTree *seg; void give_initial_chart(int H, int W, vector<int> R, vector<int> C) { ::H = H; ::W = W; ::R = R; ::C = C; ::HI = H * W; seg = new SegmentTree; } int swap_seats(int a, int b) { swap(R[a], R[b]); swap(C[a], C[b]); seg -> modify(LO, HI - 1, 0, R[a], a, true); seg -> modify(LO, HI - 1, 0, C[a], a, false); seg -> modify(LO, HI - 1, 0, R[b], b, true); seg -> modify(LO, HI - 1, 0, C[b], b, false); int res = 0; int current_idx = 0; while(current_idx < HI) { Node ans = seg -> query(0, current_idx, LO, HI - 1, 0); int score = (ans.R_max - ans.R_min + 1) * (ans.C_max - ans.C_min + 1); if (current_idx + 1 == score) { ++res; ++current_idx; } else { current_idx = score - 1; } } return res; }

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

seats.cpp: In constructor 'SegmentTree::SegmentTree()':
seats.cpp:31:30: error: no matching function for call to 'SegmentTree::build(int&, int, int, std::vector<int>&, std::vector<int>&)'
   31 |     build(LO, HI - 1, 0, R, C);
      |                              ^
seats.cpp:33:8: note: candidate: 'void SegmentTree::build(int, int, int)'
   33 |   void build(int l, int r, int node) {
      |        ^~~~~
seats.cpp:33:8: note:   candidate expects 3 arguments, 5 provided
seats.cpp: In member function 'void SegmentTree::build(int, int, int)':
seats.cpp:40:37: error: no matching function for call to 'SegmentTree::build(int&, int&, int, std::vector<int>&, std::vector<int>&)'
   40 |     build(l, mid, 2 * node + 1, R, C);
      |                                     ^
seats.cpp:33:8: note: candidate: 'void SegmentTree::build(int, int, int)'
   33 |   void build(int l, int r, int node) {
      |        ^~~~~
seats.cpp:33:8: note:   candidate expects 3 arguments, 5 provided
seats.cpp:41:41: error: no matching function for call to 'SegmentTree::build(int, int&, int, std::vector<int>&, std::vector<int>&)'
   41 |     build(mid + 1, r, 2 * node + 2, R, C);
      |                                         ^
seats.cpp:33:8: note: candidate: 'void SegmentTree::build(int, int, int)'
   33 |   void build(int l, int r, int node) {
      |        ^~~~~
seats.cpp:33:8: note:   candidate expects 3 arguments, 5 provided