# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
927080 |
2024-02-14T08:43:19 Z |
Nurislam |
Wall (IOI14_wall) |
C++14 |
|
0 ms |
0 KB |
#include "wall.h"
#include <bits/stdc++.h>
#include "grader.cpp"
using namespace std;
#define pb push_back
#define ff first
#define ss second
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
const int N = 2e6+5;
pii b[N*4]{};
int a[N]{};
void push(int i, int l, int r){
if(l == r){
if(b[i].ss == 0)return;
if(b[i].ss == 2){
a[l] = min(b[i].ff, a[l]);
}else{
a[l] = max(b[i].ff, a[l]);
}
b[i] = {0,0};
return;
}
if(b[i] == pair<int,int>({0, 0}))return;
b[i*2] = b[i];
b[i*2+1] = b[i];
b[i] = {0, 0};
}
void upd(int i, int l, int r, int tl, int tr, pii val){
push(i, l, r);
if(l > tr || r < tl || r < l)return;
if(tl <= l && r <= tr){
b[i] = val;
push(i, l, r);
return;
}
int m = (l+r)>>1;
upd(i*2, l, m, tl, tr, val);
upd(i*2+1, m+1, r, tl, tr, val);
}
int get(int i, int l, int r, int ps){
push(i, l, r);
if(l == r && l == ps)return a[ps];
int m = (l+r)>>1;
if(ps <= m)return get(i*2, l, m, ps);
else return get(i*2+1, m+1, r, ps);
}
void buildWall(int n, int k, int op[], int l[], int r[], int h[], int finalHeight[]){
for(int i = 0; i < k; i++){
upd(1, 0, n-1, l[i], r[i], {h[i], op[i]});
//~ for(int i = 0; i < n; i++){
//~ finalHeight[i] = get(1, 0, n-1, i);
//~ cout << a[i] << ' ';
//~ }cout << '\n';
}
for(int i = 0; i < n; i++){
finalHeight[i] = get(1, 0, n-1, i);
//~ cout << a[i] << ' ';
}
//~ cout << '\n';
return;
}
Compilation message
/usr/bin/ld: /tmp/ccgrsvU2.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc4jiEV0.o:wall.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status