# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
986856 |
2024-05-21T12:17:17 Z |
emad234 |
Wall (IOI14_wall) |
C++17 |
|
155 ms |
54412 KB |
#pragma once
#include "bits/stdc++.h"
#define F first
#define S second
#define ll long long
#define pii pair<int,int>
const int mxN = (1 << 20);
const int mod = 1e9 + 7;
const int inf = INT_MAX;
using namespace std;
struct event{
int ty,op,id,val;
};
vector<event>q[mxN];
pii seg[mxN];
int N,s,e;
pii combine(pii a,pii b){
pii c;
c.F = min(a.F,b.S);
c.F = max(c.F,b.F);
c.S = min(a.S,b.S);
return c;
}
void update(int ind,pii val){
ind += N;
seg[ind] = val;
while(ind /= 2) seg[ind] = combine(seg[ind * 2],seg[ind * 2 + 1]);
}
void printseg(){
int ex = 1;
for(int i = 1;i < N * 2;i++){
cout<<"{ "<<seg[i].F<<" , ";
if(seg[i].S == inf) cout<<"inf";
else cout<<seg[i].S;
cout<<" } ";
if(ex * 2 - 1 == i){
ex *= 2;
cout<<'\n';
}
}
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
N = exp2(ceil(log2(n)));
for(int i = 1;i < N * 2;i++){
seg[i] = {0,inf};
}
for(int i = 0;i < k;i++){
q[left[i]].push_back({1,op[i],i,height[i]});
q[right[i] + 1].push_back({-1,op[i],i,height[i]});
}
for(int i = 0;i < n;i++){
while(q[i].size()){
auto u = q[i].back();
q[i].pop_back();
if(u.ty == -1){
update(u.id,{0,inf});
}else{
if(u.op == 1) update(u.id,{u.val,inf});
else update(u.id, {0,u.val});
}
finalHeight[i] = seg[1].F;
}
}
}
Compilation message
wall.cpp:1:9: warning: #pragma once in main file
1 | #pragma once
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
26712 KB |
Output is correct |
2 |
Incorrect |
12 ms |
27228 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
26712 KB |
Output is correct |
2 |
Incorrect |
155 ms |
54412 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
26712 KB |
Output is correct |
2 |
Incorrect |
10 ms |
27228 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
26716 KB |
Output is correct |
2 |
Incorrect |
10 ms |
27228 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |