제출 #119082

#제출 시각아이디문제언어결과실행 시간메모리
119082SOIVIEONE벽 (IOI14_wall)C++14
0 / 100
949 ms262144 KiB
#include <bits/stdc++.h> #include "wall.h" //#include <ext/pb_ds/assoc_container.hpp> #define INF 1000000021 #define MOD 1000000007 #define pb push_back #define sqr(a) (a)*(a) #define M(a, b) make_pair(a,b) #define T(a, b, c) make_pair(a, make_pair(b, c)) #define F first #define S second #define all(x) (x.begin(), x.end()) #define deb(x) cerr << #x << " = " << x << '\n' #define N 2222222 using namespace std; //using namespace __gnu_pbds; typedef long double ld; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<ll> vll; //typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set; const ld pi = 2 * acos(0.0); template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;} template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;} template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;} //int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31}; vector<pair<ll, pll> > adl[N], adr[N], reml[N], remr[N]; void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]) { for(int i = 0; i < k; i ++) { if(op[i] == 1) { adl[left[i]].pb(M(height[i], M(i, 1))); if(right[i] + 1 < n) adr[right[i] + 1].pb(M(height[i], M(i, 1))); } else { reml[left[i]].pb(M(height[i], M(i, 2))); if(right[i] + 1 < n) remr[right[i] + 1].pb(M(height[i], M(i, 2))); } } multiset<pair<ll,pll> > foo, hoo; for(int i = 0; i < n; i ++) { for(auto it : remr[i]) hoo.erase(hoo.find(it)); for(auto it : adr[i]) foo.erase(foo.find(it)); for(auto it : adl[i]) foo.insert(it); for(auto it : reml[i]) hoo.insert(it); if(foo.empty()) { finalHeight[i] = 0; continue; } auto ii = foo.end(); ii--; pair<ll, pll> fo = *ii; if(hoo.empty()) { finalHeight[i] = fo.F; continue; } ii = hoo.begin(); pair<ll, pll> ho = *ii; ll res = 0; if(fo.S.F < ho.S.F) { res = fo.F; umin(res, ho.F); } else { res = fo.F; } finalHeight[i] = res; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...