Submission #948350

#TimeUsernameProblemLanguageResultExecution timeMemory
948350irmuunWall (IOI14_wall)C++17
100 / 100
564 ms104788 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define ff first #define ss second #define all(s) s.begin(),s.end() #define rall(s) s.rbegin(),s.rend() struct segtree{ int n; vector<int>d,u,ans; segtree(int n):n(n){ d.resize(4*n); u.resize(4*n); ans.resize(n); build(1,0,n-1); } void combine(int node,int D,int U){ d[node]=min(d[node],D); d[node]=max(d[node],U); u[node]=max(u[node],U); u[node]=min(u[node],D); } void build(int node,int l,int r){ if(l==r){ d[node]=1e9; u[node]=0; return; } int mid=(l+r)/2; build(node*2,l,mid); build(node*2+1,mid+1,r); } void update(int node,int l,int r,int L,int R,int val,int type){ if(L>R||r<L||R<l) return; if(L<=l&&r<=R){ if(type==1){ d[node]=max(d[node],val); u[node]=max(u[node],val); } else{ d[node]=min(d[node],val); u[node]=min(u[node],val); } return; } combine(node*2,d[node],u[node]); combine(node*2+1,d[node],u[node]); d[node]=1e9; u[node]=0; int mid=(l+r)/2; update(node*2,l,mid,L,R,val,type); update(node*2+1,mid+1,r,L,R,val,type); } void findAns(int node,int l,int r){ if(l==r){ ans[l]=min(d[node],u[node]); return; } combine(node*2,d[node],u[node]); combine(node*2+1,d[node],u[node]); int mid=(l+r)/2; findAns(node*2,l,mid); findAns(node*2+1,mid+1,r); } vector<int>f(){ return ans; } }; void buildWall(int n, int k, int op[], int l[], int r[], int h[], int H[]){ segtree sg(n); for(int i=0;i<k;i++){ sg.update(1,0,n-1,l[i],r[i],h[i],op[i]); } sg.findAns(1,0,n-1); vector<int>v=sg.f(); for(int i=0;i<n;i++){ H[i]=v[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...