제출 #635264

#제출 시각아이디문제언어결과실행 시간메모리
635264ghostwriter벽 (IOI14_wall)C++14
100 / 100
859 ms107104 KiB
#include "wall.h" #include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include <debug.h> #include "grader.cpp" #endif #define st first #define nd second #define pb push_back #define pf push_front #define _pb pop_back #define _pf pop_front #define lb lower_bound #define ub upper_bound #define mtp make_tuple #define all(x) (x).begin(), (x).end() #define sz(x) (int)(x).size() typedef long long ll; typedef unsigned long long ull; typedef double db; typedef long double ldb; typedef pair<int, int> pi; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<pi> vpi; typedef vector<pll> vpll; typedef string str; template<typename T> T gcd(T a, T b) { return (b == 0? a : gcd(b, a % b)); } template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; } #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i)) #define FOS(i, r, l) for (int (i) = (r); (i) >= (l); --(i)) #define EACH(i, x) for (auto &(i) : (x)) #define WHILE while #define file "TEST" mt19937 rd(chrono::steady_clock::now().time_since_epoch().count()); ll rand(ll l, ll r) { return uniform_int_distribution<ll>(l, r)(rd); } /* Tran The Bao CTL - Da Lat Cay ngay cay dem nhung deo duoc cong nhan */ const int oo = 1e9; const int T = 8e6 + 1; const int N = 2e6 + 1; int n, k, ans[N]; pi tr[T]; pi comb(pi a, pi b) { pi rs = a; rs.st = min(rs.st, b.st); rs.nd = min(rs.nd, b.st); rs.nd = max(rs.nd, b.nd); return rs; } void lazy(int i, int l, int r) { if (l != r) { tr[i * 2] = comb(tr[i * 2], tr[i]); tr[i * 2 + 1] = comb(tr[i * 2 + 1], tr[i]); tr[i] = {oo, -oo}; } } void upd(int i, int l, int r, int ql, int qr, pi v) { lazy(i, l, r); if (r < ql || l > qr) return; if (ql <= l && r <= qr) { tr[i] = comb(tr[i], v); lazy(i, l, r); return; } int mid = l + (r - l) / 2; upd(i * 2, l, mid, ql, qr, v); upd(i * 2 + 1, mid + 1, r, ql, qr, v); } void dfs(int i, int l, int r) { lazy(i, l, r); if (l == r) { ans[l] = max(0, tr[i].nd); return; } int mid = l + (r - l) / 2; dfs(i * 2, l, mid); dfs(i * 2 + 1, mid + 1, r); } void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){ ::n = n; ::k = k; FOR(i, 1, 4 * n) tr[i] = {oo, -oo}; FOR(i, 0, k - 1) { int t = op[i], l = left[i], r = right[i], h = height[i]; pi tmp; if (t == 1) tmp = {oo, h}; else tmp = {h, -oo}; upd(1, 0, n - 1, l, r, tmp); } dfs(1, 0, n - 1); FOR(i, 0, n - 1) finalHeight[i] = ans[i]; return; } /* 10 6 1 1 8 4 2 4 9 1 2 3 6 5 1 0 5 3 1 2 2 5 2 6 7 0 */

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

wall.cpp: In function 'void buildWall(int, int, int*, int*, int*, int*, int*)':
wall.cpp:26:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   26 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
wall.cpp:82:5: note: in expansion of macro 'FOR'
   82 |     FOR(i, 1, 4 * n) tr[i] = {oo, -oo};
      |     ^~~
wall.cpp:26:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   26 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
wall.cpp:83:5: note: in expansion of macro 'FOR'
   83 |     FOR(i, 0, k - 1) {
      |     ^~~
wall.cpp:26:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   26 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
wall.cpp:91:5: note: in expansion of macro 'FOR'
   91 |     FOR(i, 0, n - 1) finalHeight[i] = ans[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...