제출 #978169

#제출 시각아이디문제언어결과실행 시간메모리
978169shezitt벽 (IOI14_wall)C++14
0 / 100
1740 ms262144 KiB
#include "wall.h" #include <bits/stdc++.h> using namespace std; #define fore(a, b, c) for(int a=b; a<c; ++a) #define sz(x) (int) x.size() #define all(x) x.begin(), x.end() #define ii pair<int,int> #define vi vector<int> struct segtree { vi t; int n; vector<set<array<int,3>>> lazy; segtree(int n) : n(n) { t.assign(4*n, 0); lazy.assign(4*n, {}); } void updateMx(int i, int tl, int tr, int l, int r, int val, int id){ if(l <= tl && tr <= r){ lazy[i].insert({id, 1, val}); return; } if(r < tl or tr < l){ return; } int tm = (tl + tr) / 2; updateMx(2*i+1, tl, tm, l, r, val, id); updateMx(2*i+2, tm+1, tr, l, r, val, id); } void updateMx(int l, int r, int val, int id){ updateMx(0, 0, n-1, l, r, val, id); } void updateMn(int i, int tl, int tr, int l, int r, int val, int id){ if(l <= tl && tr <= r){ lazy[i].insert({id, 2, val}); return; } if(r < tl or tr < l){ return; } int tm = (tl + tr) / 2; updateMn(2*i+1, tl, tm, l, r, val, id); updateMn(2*i+2, tm+1, tr, l, r, val, id); } void updateMn(int l, int r, int val, int id){ updateMn(0, 0, n-1, l, r, val, id); } void push(int i, int tl, int tr){ lazy[2*i+1].insert(all(lazy[i])); lazy[2*i+2].insert(all(lazy[i])); lazy[i].clear(); } int query(int i, int tl, int tr, int idx){ if(tl == tr){ for(auto [id, type, val] : lazy[i]){ if(t[i] == -1){ t[i] = val; continue; } if(type == 1){ t[i] = max(t[i], val); } else { t[i] = min(t[i], val); } } return t[i]; } push(i, tl, tr); int tm = (tl + tr) / 2; if(idx <= tm){ return query(2*i+1, tl, tm, idx); } else { return query(2*i+2, tm+1, tr, idx); } } int query(int idx){ return query(0, 0, n-1, idx); } }; void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){ segtree T(n); fore(i, 0, k){ if(op[i] == 1){ T.updateMx(left[i], right[i], height[i], i); } else { cerr << "minimo update" << endl; T.updateMn(left[i], right[i], height[i], i); cerr << "minimo update" << endl; } } fore(i, 0, n){ finalHeight[i] = T.query(i); } return; }

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

wall.cpp: In member function 'int segtree::query(int, int, int, int)':
wall.cpp:64:22: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   64 |             for(auto [id, type, val] : lazy[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...