제출 #422888

#제출 시각아이디문제언어결과실행 시간메모리
422888fedoseevtimofey벽 (IOI14_wall)C++14
100 / 100
766 ms152164 KiB
#include <iostream> #include <string> #include <vector> #include <queue> #include <deque> #include <stack> #include <set> #include <map> #include <unordered_map> #include <unordered_set> #include <cstring> #include <cmath> #include <cstdlib> #include <algorithm> #include <random> #include <iomanip> #include <functional> #include <cassert> #include <bitset> #include <chrono> using namespace std; typedef long long ll; #include "wall.h" const int Inf = 1e9; struct Chel { int l, r; Chel() : l(0), r(Inf) {} Chel(int l, int r) : l(l), r(r) {} Chel operator +(const Chel &other) const { if (r < other.l) return Chel(other.l, other.l); if (l > other.r) return Chel(other.r, other.r); return Chel(max(l, other.l), min(r, other.r)); } }; const int N = 1 << 19; Chel t[1 << 20]; int sz; void modify(int pos, Chel val) { t[N + pos] = val; //cout << "add " << pos << ' ' << val.l << ' ' << val.r << endl; for (int i = (N + pos) / 2; i >= 1; i /= 2) { t[i] = t[2 * i] + t[2 * i + 1]; } } void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){ //cout << k << endl; vector <vector <int>> beg(n), en(n); for (int i = 0; i < k; ++i) { beg[left[i]].push_back(i); en[right[i]].push_back(i); } for (int i = 0; i < n; ++i) { for (int id : beg[i]) { if (op[id] == 1) { modify(id, Chel(height[id], Inf)); } else { modify(id, Chel(0, height[id])); } } //cout << "go " << i << ' ' << t[1].l << ' ' << t[1].r << endl; finalHeight[i] = t[1].l; for (int id : en[i]) { modify(id, Chel()); } } } #ifdef LOCAL int main() { ios_base::sync_with_stdio(false); cin.tie(0); #ifdef LOCAL freopen("input.txt", "r", stdin); #endif int n; int k; int i, j; int status = 0; cin >> n >> k; int* op = (int*)calloc(sizeof(int), k); int* left = (int*)calloc(sizeof(int), k); int* right = (int*)calloc(sizeof(int), k); int* height = (int*)calloc(sizeof(int), k); int* finalHeight = (int*)calloc(sizeof(int), n); for (i = 0; i < k; i++){ cin >> op[i] >> left[i] >> right[i] >> height[i]; } buildWall(n, k, op, left, right, height, finalHeight); for (j = 0; j < n; j++) printf("%d\n", finalHeight[j]); return 0; } #endif
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...