# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
986861 |
2024-05-21T12:40:02 Z |
emad234 |
Wall (IOI14_wall) |
C++17 |
|
482 ms |
176620 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 << 22);
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 = a;
c.F = min(c.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 buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
// N = exp2(ceil(log2(n)));
N = 1 << 20;
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 |
55 ms |
117044 KB |
Output is correct |
2 |
Correct |
56 ms |
117584 KB |
Output is correct |
3 |
Correct |
55 ms |
117336 KB |
Output is correct |
4 |
Correct |
56 ms |
117588 KB |
Output is correct |
5 |
Correct |
60 ms |
117840 KB |
Output is correct |
6 |
Correct |
58 ms |
117736 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
62 ms |
117072 KB |
Output is correct |
2 |
Correct |
213 ms |
143776 KB |
Output is correct |
3 |
Correct |
159 ms |
132148 KB |
Output is correct |
4 |
Correct |
378 ms |
156320 KB |
Output is correct |
5 |
Correct |
273 ms |
153432 KB |
Output is correct |
6 |
Correct |
292 ms |
151724 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
56 ms |
116964 KB |
Output is correct |
2 |
Correct |
55 ms |
117504 KB |
Output is correct |
3 |
Correct |
54 ms |
117328 KB |
Output is correct |
4 |
Correct |
56 ms |
117584 KB |
Output is correct |
5 |
Correct |
56 ms |
117716 KB |
Output is correct |
6 |
Correct |
56 ms |
117548 KB |
Output is correct |
7 |
Correct |
61 ms |
117072 KB |
Output is correct |
8 |
Correct |
211 ms |
143784 KB |
Output is correct |
9 |
Correct |
155 ms |
132692 KB |
Output is correct |
10 |
Correct |
401 ms |
156524 KB |
Output is correct |
11 |
Correct |
275 ms |
153584 KB |
Output is correct |
12 |
Correct |
262 ms |
151572 KB |
Output is correct |
13 |
Correct |
52 ms |
117072 KB |
Output is correct |
14 |
Correct |
241 ms |
144068 KB |
Output is correct |
15 |
Correct |
70 ms |
119892 KB |
Output is correct |
16 |
Correct |
377 ms |
156740 KB |
Output is correct |
17 |
Correct |
265 ms |
151828 KB |
Output is correct |
18 |
Correct |
265 ms |
151064 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
54 ms |
117076 KB |
Output is correct |
2 |
Correct |
54 ms |
117588 KB |
Output is correct |
3 |
Correct |
54 ms |
117184 KB |
Output is correct |
4 |
Correct |
55 ms |
117588 KB |
Output is correct |
5 |
Correct |
55 ms |
117508 KB |
Output is correct |
6 |
Correct |
56 ms |
117560 KB |
Output is correct |
7 |
Correct |
53 ms |
117076 KB |
Output is correct |
8 |
Correct |
223 ms |
143780 KB |
Output is correct |
9 |
Correct |
155 ms |
132680 KB |
Output is correct |
10 |
Correct |
379 ms |
156504 KB |
Output is correct |
11 |
Correct |
274 ms |
153444 KB |
Output is correct |
12 |
Correct |
261 ms |
151632 KB |
Output is correct |
13 |
Correct |
53 ms |
117072 KB |
Output is correct |
14 |
Correct |
267 ms |
143780 KB |
Output is correct |
15 |
Correct |
70 ms |
119904 KB |
Output is correct |
16 |
Correct |
383 ms |
156752 KB |
Output is correct |
17 |
Correct |
298 ms |
152024 KB |
Output is correct |
18 |
Correct |
275 ms |
150980 KB |
Output is correct |
19 |
Correct |
448 ms |
176532 KB |
Output is correct |
20 |
Correct |
439 ms |
173928 KB |
Output is correct |
21 |
Correct |
482 ms |
176596 KB |
Output is correct |
22 |
Correct |
445 ms |
174172 KB |
Output is correct |
23 |
Correct |
440 ms |
174044 KB |
Output is correct |
24 |
Correct |
432 ms |
173984 KB |
Output is correct |
25 |
Correct |
431 ms |
173932 KB |
Output is correct |
26 |
Correct |
434 ms |
176620 KB |
Output is correct |
27 |
Correct |
448 ms |
176388 KB |
Output is correct |
28 |
Correct |
429 ms |
174032 KB |
Output is correct |
29 |
Correct |
429 ms |
173904 KB |
Output is correct |
30 |
Correct |
466 ms |
173952 KB |
Output is correct |