Submission #668711

#TimeUsernameProblemLanguageResultExecution timeMemory
668711ktkeremWall (IOI14_wall)C++17
0 / 100
145 ms13888 KiB
/*#pragma GCC target ("avx2") #pragma GCC optimize ("O3") #pragma GCC optimize("Ofast") #pragma GCC optimize ("unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")/**/ #include<bits/stdc++.h> #include<wall.h> /**/ //typedef int ll; typedef long long ll; typedef unsigned long long ull; typedef std::string str; //typedef vector<std::vector<ll>> vv; /*typedef __int128 vll; typedef unsigned __int128 uvll;*/ #define llll std::pair<ll , ll> #define pb push_back #define pf push_front #define halo cout << "hello\n" #define fi first #define sec second #define vv(x) std::vector<std::vector<x>> #define all(a) a.begin() , a.end() const ll limit = 1e15+7; const ll ous = 2e5 + 7; const ll dx[4] = {-1 , 0 , 1 , 0} , dy[4] = {0,1,0,-1}; struct node{ ll mx = 0 , smx = -1 , mn = 0 , smn = limit; }; std::vector<node> valt; void push(ll l , ll r , ll a){ if(a == 1){ return; } if(l == r){ if(valt[a].mx > valt[a/2].mx){ valt[a].mx = valt[a/2].mx; valt[a].mn = valt[a/2].mx; } else if(valt[a].mn < valt[a/2].mn){ valt[a].mx = valt[a/2].mn; valt[a].mn = valt[a/2].mn; } } else{ if(valt[a].mx == valt[a].smn){ valt[a].smn = std::min(valt[a].mx , valt[a/2].mx); } valt[a].mx = std::min(valt[a].mx , valt[a/2].mx); if(valt[a].mn == valt[a].smx){ valt[a].smx = std::max(valt[a].mn , valt[a/2].mn); } valt[a].mn = std::max(valt[a].mn , valt[a/2].mn); } } void mxque(ll l , ll r , ll nl , ll nr , ll a , ll val){ push(nl , nr , a); if(l > nr || r < nl || val <= valt[a].mn){ return; } else if(r >= nr && l <= nl && valt[a].smn > val){ valt[a].mn = val; if(nl == nr){ valt[a].mx = val; } return; } ll md=(nl+nr)/2; mxque(l , r , nl , md , a*2 , val); mxque(l , r , md+1 , nr , a*2+1 , val); if(valt[a*2+1].mx == valt[a*2].mx){ valt[a].mx = valt[a*2].mx; valt[a].smx = std::max(valt[a*2+1].smx , valt[a*2].smx); } else{ if(valt[a*2+1].mx > valt[a*2].mx){ valt[a].mx = valt[a*2+1].mx; valt[a].smx = std::max(valt[a*2+1].smx , valt[a*2].mx); } else{ valt[a].mx = valt[a*2].mx; valt[a].smx = std::max(valt[a*2].smx , valt[a*2+1].mx); } } if(valt[a*2+1].mn == valt[a*2].mn){ valt[a].mn = valt[a*2].mn; valt[a].smn = std::min(valt[a*2+1].smn , valt[a*2].smn); } else{ if(valt[a*2+1].mn < valt[a*2].mn){ valt[a].mn = valt[a*2+1].mn; valt[a].smn = std::min(valt[a*2+1].smn , valt[a*2].mn); } else{ valt[a].mn = valt[a*2].mn; valt[a].smx = std::max(valt[a*2].smn , valt[a*2+1].mn); } } } void mnque(ll l , ll r , ll nl , ll nr , ll a , ll val){ push(nl , nr , a); if(l > nr || r < nl || val >= valt[a].mx){ return; } else if(r >= nr && l <= nl && valt[a].smx < val){ valt[a].mx = val; if(nl == nr){ valt[a].mn = val; } return; } ll md=(nl+nr)/2; mnque(l , r , nl , md , a*2 , val); mnque(l , r , md+1 , nr , a*2+1 , val); if(valt[a*2+1].mx == valt[a*2].mx){ valt[a].mx = valt[a*2].mx; valt[a].smx = std::max(valt[a*2+1].smx , valt[a*2].smx); } else{ if(valt[a*2+1].mx > valt[a*2].mx){ valt[a].mx = valt[a*2+1].mx; valt[a].smx = std::max(valt[a*2+1].smx , valt[a*2].mx); } else{ valt[a].mx = valt[a*2].mx; valt[a].smx = std::max(valt[a*2].smx , valt[a*2+1].mx); } } if(valt[a*2+1].mn == valt[a*2].mn){ valt[a].mn = valt[a*2].mn; valt[a].smn = std::min(valt[a*2+1].smn , valt[a*2].smn); } else{ if(valt[a*2+1].mn < valt[a*2].mn){ valt[a].mn = valt[a*2+1].mn; valt[a].smn = std::min(valt[a*2+1].smn , valt[a*2].mn); } else{ valt[a].mn = valt[a*2].mn; valt[a].smx = std::max(valt[a*2].smn , valt[a*2+1].mn); } } } void retans(ll l , ll r , ll a , int ans[]){ if(l == r){ ans[l] = valt[a].mx; return; } ll md = (l + r)/2; retans(l , md , a*2 , ans); retans(md+1 , r , a*2+1 , ans); } /*void solve(){ std::cin >> n >> m; for(ll i =1;n>i;i++){ ll x;std::cin >> x; adj[x].pb(i); adj[i].pb(x); } llll ans = dfs(0 , -1); std::cout << ans.fi << "\n"; return; }*/ void ltss(ll ot[]){ ot[0] = 5; return; } void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){ valt.resize(n*4); for(ll i = 0;k>i;i++){ if(op[i] == 1){ mxque(left[i] , right[i] , 0ll , n-1 , 1 , height[i]); } else{ mnque(left[i] , right[i] , 0ll , n-1 , 1 , height[i]); } } retans(0 , n-1 , 1 , finalHeight); } /*signed main(){ std::ios_base::sync_with_stdio(false);std::cin.tie(NULL); ll t=1; //std::cin >> t; ll o = 1; while(t--){ //cout << "Case " << o++ << ":\n"; //solve(); } return 0; }/**/

Compilation message (stderr)

wall.cpp:5:78: warning: "/*" within comment [-Wcomment]
    5 | #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")/**/
      |                                                                               
wall.cpp:190:2: warning: "/*" within comment [-Wcomment]
  190 | }/**/
      |
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...