Submission #424122

#TimeUsernameProblemLanguageResultExecution timeMemory
424122SAADWall (IOI14_wall)C++17
24 / 100
386 ms23236 KiB
#define F first #define S second #define rep(i,a,b) for(int i=a;!(a==b&&i!=b)&&((i<=b&&b>=a)||(i>=b&&a>=b));i+=(a<=b?1:-1)) #define pb push_back #define Fbitl __builtin_ffs #define bit1 __builtin_popcount //#include <bits/stdc++.h> #include <iostream> #include <math.h> #include <algorithm> #include <string.h> #include <vector> #include <queue> #include <map> #include <unordered_map> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<string, string> pss; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<pii> vii; typedef vector<ll> vl; typedef vector<vl> vvl; #include "wall.h" bool th ; int seg[(int)1e6 + 1] , L , R , num ; int n , nn ; void segmant ( int idx , int l , int r ) { if (idx >= nn+n) return; //cout << idx << " : (" << l <<','<<r<<")\n" ; if ( l >= L && r <= R ) { if ( th ) seg[idx] = (seg[idx]==-1?num:min(seg[idx],num)); else seg[idx] = (seg[idx]==-1?num:max(seg[idx],num)); } else if ( l > R || r < L ) return; else { segmant(idx*2,l,(l+r)/2); segmant((idx*2)+1,((l+r)/2)+1,r); } } int mx ( int idx ) { if (idx==1) return seg[1]; int res = max(seg[idx],mx(idx/2)); return res; } int mn ( int idx ) { if (idx==1) return (seg[1]==-1?(int)1e6:seg[1]); int res = min((seg[idx]==-1?(int)1e6:seg[idx]),mn(idx/2)); return res; } void buildWall(int n, int k, int op[], int left[], int right[],int height[], int finalHeight[]) { ::n = n; nn = (pow(2,(int)log2(n))==n?pow(2,(int)log2(n)):pow(2,(int)(log2(n))+1) ) ; int c = 0; while (op[c] == 1 && c < k) { num = height[c];L = left[c];R = right[c]; segmant(1,0,nn-1); c++; } for (int i=0;i<n;i++) { finalHeight[i] = mx(i+nn); //cout << i+nn << " " << finalHeight[i] << endl ; } memset(seg,-1,sizeof(seg)); th = true; while (op[c] == 2 && c < k) { num = height[c];L = left[c];R = right[c]; segmant(1,0,nn-1); c++; } for (int i=0;i<n;i++) finalHeight[i] = min(finalHeight[i],mn(i+nn)); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...