# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
779133 |
2023-07-11T08:14:29 Z |
fatemetmhr |
Wall (IOI14_wall) |
C++17 |
|
859 ms |
97112 KB |
// ~ Be Name Khoda ~ //
#include "wall.h"
#include <bits/stdc++.h>
//#pragma GCC optimize ("O3")
//#pragma GCC target("avx2")
//#pragma GCC optimize("unroll-loops,Ofast")
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define fi first
#define se second
const int maxn = 8e6 + 10;
const int maxn5 = 2e6 + 10;
const int maxnt = 8e6 + 10;
const int maxn3 = 1e3 + 10;
const int mod = 1e9 + 7;
const ll inf = 1e18;
void upd(int, int, int, int, int, int, int);
int ret[maxn5], segl[maxnt], segr[maxnt];
void shift(int l, int mid, int r, int v){
upd(l, mid, l, mid, 1, segl[v], v * 2);
upd(l, mid, l, mid, 2, segr[v], v * 2);
upd(mid, r, mid, r, 1, segl[v], v * 2 + 1);
upd(mid, r, mid, r, 2, segr[v], v * 2 + 1);
segl[v] = 0;
segr[v] = mod;
}
void upd(int l, int r, int lq, int rq, int ty, int k, int v){
if(rq <= l || r <= lq)
return;
if(lq <= l && r <= rq){
if(ty == 1){
segl[v] = max(segl[v], k);
segr[v] = max(segr[v], segl[v]);
}
else{
segr[v] = min(segr[v], k);
segl[v] = min(segl[v], segr[v]);
}
return;
}
int mid = (l + r) >> 1; shift(l, mid, r, v);
upd(l, mid, lq, rq, ty, k, v * 2);
upd(mid, r, lq, rq, ty, k, v * 2 + 1);
}
void shift_all(int l, int r, int v){
if(r - l == 1){
ret[l] = segl[v];
return;
}
int mid = (l + r) >> 1;
shift(l, mid, r, v);
shift_all(l, mid, v * 2);
shift_all(mid, r, v * 2 + 1);
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
fill(segl, segl + maxnt, 0);
fill(segr, segr + maxnt, mod);
for(int i = 0; i < k; i++)
upd(0, n, left[i], right[i] + 1, op[i], height[i], 1);
shift_all(0, n, 1);
for(int i = 0; i < n; i++)
finalHeight[i] = ret[i];
return;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
62932 KB |
Output is correct |
2 |
Correct |
26 ms |
63004 KB |
Output is correct |
3 |
Correct |
24 ms |
62848 KB |
Output is correct |
4 |
Correct |
31 ms |
63128 KB |
Output is correct |
5 |
Correct |
29 ms |
63144 KB |
Output is correct |
6 |
Correct |
29 ms |
63016 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
62828 KB |
Output is correct |
2 |
Correct |
134 ms |
70736 KB |
Output is correct |
3 |
Correct |
209 ms |
66328 KB |
Output is correct |
4 |
Correct |
574 ms |
71692 KB |
Output is correct |
5 |
Correct |
377 ms |
72172 KB |
Output is correct |
6 |
Correct |
396 ms |
72192 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
62804 KB |
Output is correct |
2 |
Correct |
26 ms |
62876 KB |
Output is correct |
3 |
Correct |
26 ms |
62932 KB |
Output is correct |
4 |
Correct |
34 ms |
63128 KB |
Output is correct |
5 |
Correct |
29 ms |
63060 KB |
Output is correct |
6 |
Correct |
30 ms |
63060 KB |
Output is correct |
7 |
Correct |
30 ms |
62812 KB |
Output is correct |
8 |
Correct |
135 ms |
70704 KB |
Output is correct |
9 |
Correct |
211 ms |
66304 KB |
Output is correct |
10 |
Correct |
573 ms |
71720 KB |
Output is correct |
11 |
Correct |
377 ms |
72212 KB |
Output is correct |
12 |
Correct |
363 ms |
72132 KB |
Output is correct |
13 |
Correct |
24 ms |
62812 KB |
Output is correct |
14 |
Correct |
135 ms |
70676 KB |
Output is correct |
15 |
Correct |
54 ms |
63500 KB |
Output is correct |
16 |
Correct |
562 ms |
71916 KB |
Output is correct |
17 |
Correct |
389 ms |
71884 KB |
Output is correct |
18 |
Correct |
396 ms |
71976 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
62820 KB |
Output is correct |
2 |
Correct |
27 ms |
62972 KB |
Output is correct |
3 |
Correct |
25 ms |
62924 KB |
Output is correct |
4 |
Correct |
32 ms |
63044 KB |
Output is correct |
5 |
Correct |
30 ms |
63060 KB |
Output is correct |
6 |
Correct |
29 ms |
63124 KB |
Output is correct |
7 |
Correct |
25 ms |
62908 KB |
Output is correct |
8 |
Correct |
135 ms |
70684 KB |
Output is correct |
9 |
Correct |
208 ms |
66272 KB |
Output is correct |
10 |
Correct |
616 ms |
71660 KB |
Output is correct |
11 |
Correct |
413 ms |
72176 KB |
Output is correct |
12 |
Correct |
365 ms |
72168 KB |
Output is correct |
13 |
Correct |
25 ms |
62812 KB |
Output is correct |
14 |
Correct |
138 ms |
70772 KB |
Output is correct |
15 |
Correct |
53 ms |
63536 KB |
Output is correct |
16 |
Correct |
567 ms |
71908 KB |
Output is correct |
17 |
Correct |
373 ms |
71904 KB |
Output is correct |
18 |
Correct |
402 ms |
71916 KB |
Output is correct |
19 |
Correct |
825 ms |
96644 KB |
Output is correct |
20 |
Correct |
804 ms |
94628 KB |
Output is correct |
21 |
Correct |
845 ms |
97112 KB |
Output is correct |
22 |
Correct |
814 ms |
94572 KB |
Output is correct |
23 |
Correct |
815 ms |
94668 KB |
Output is correct |
24 |
Correct |
826 ms |
94580 KB |
Output is correct |
25 |
Correct |
805 ms |
94572 KB |
Output is correct |
26 |
Correct |
810 ms |
97004 KB |
Output is correct |
27 |
Correct |
824 ms |
97036 KB |
Output is correct |
28 |
Correct |
813 ms |
94444 KB |
Output is correct |
29 |
Correct |
859 ms |
94448 KB |
Output is correct |
30 |
Correct |
817 ms |
94540 KB |
Output is correct |