# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1043512 |
2024-08-04T10:26:28 Z |
mindiyak |
Wall (IOI14_wall) |
C++14 |
|
0 ms |
0 KB |
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
#define FOR(i, a, b) for (ll i = a; i < (b); i++)
#define F0R(i, a) for (ll i = 0; i < (a); i++)
#define FORd(i, a, b) for (ll i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (ll i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto &a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)
#define len(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fst first
#define nl endl
#define sec second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define ins insert
const int MOD = 1000000007;
const int MX = INT_MAX;
const int MN = INT_MIN;
#include "wall.h"
vi seg1,seg2;
void update(int pos,int l,int r,int ql,int qr,int val,int type){
if(ql>r||qr<l)return;
if(l<=ql && qr<=r){
if(type == 1){
seg1[pos] = max(seg1[pos],val);
}else{
seg2[pos] = min(seg2[pos],val);
}
}
int mid = (l+r)/2;
update(2*pos+1,l,mid,ql,qr,val,type);
update(2*pos+2,mid+1,r,ql,qr,val,type);
}
int get(int pos,int l,int r,int index,int val,int type){
if(l == r){
if(type == 1){
return max(val,seg1[pos]);
}else{
return min(val,seg2[pos]);
}
}
int mid = (l+r)/2;
if(type == 1){
val = max(val,seg1[pos]);
}else{
val = min(val,seg2[pos]);
}
if(index <= mid)
return get(2*pos+1,l,mid,index,val,type);
else
return get(2*pos+2,mid+1,r,index,val,type);
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
FOR(i,0,n)finalHeight[i] = 0;
seg1 = vi(4*n + 5,0);
seg2 = vi(4*n + 5,2e9);
FOR(i,0,k){
update(0,0,n-1,left[i],right[i],height[i],op[i]);
}
FOR(i,0,N){
finalHeight[i] = get(0,0,n-1,i,0,1);
finalHeight[i] = min(get(0,0,n-1,i,2e9,2),finalHeight[i]);
}
}
Compilation message
wall.cpp: In function 'void buildWall(int, int, int*, int*, int*, int*, int*)':
wall.cpp:89:11: error: 'N' was not declared in this scope
89 | FOR(i,0,N){
| ^
wall.cpp:17:42: note: in definition of macro 'FOR'
17 | #define FOR(i, a, b) for (ll i = a; i < (b); i++)
| ^