# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
219216 |
2020-04-04T15:45:05 Z |
summitwei |
Wall (IOI14_wall) |
C++17 |
|
259 ms |
29176 KB |
#include <bits/stdc++.h>
#include <wall.h>
using namespace std;
typedef vector<int> vi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vll;
#define INF 0x3f3f3f3f
#define MOD 1000000009LL
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for (ll i=(a); i<=(signed)(b); i++)
#define F0R(i, a) for (ll i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (ll i=(a); i >= b; i--)
#define MN 100005
struct Node{
int lzl, lzr;
int l, r;
Node() : l(-INF), r(INF), lzl(-INF), lzr(INF) {}
};
void push(Node *a, int lr, int rr){
if(a->l < lr) a->l = lr;
if(a->l > rr) a->l = rr;
if(a->r < lr) a->r = lr;
if(a->r > rr) a->r = rr;
}
void add(Node *a, int lr, int rr){
if(a->lzl < lr) a->lzl = lr;
if(a->lzl > rr) a->lzl = rr;
if(a->lzr < lr) a->lzr = lr;
if(a->lzr > rr) a->lzr = rr;
}
Node tree[MN];
void upd(int node, int a, int b, int i, int j, int l, int r){
if(a > j || b < i) return;
if(i <= a && b <= j){
add(tree+node, l, r);
return;
}
push(tree+node, tree[node].lzl, tree[node].lzr);
if(a != b){
add(tree+node*2, tree[node].lzl, tree[node].lzr);
add(tree+node*2+1, tree[node].lzl, tree[node].lzr);
}
tree[node].lzl = -INF; tree[node].lzr = INF;
upd(node*2, a, (a+b)/2, i, j, l, r);
upd(node*2+1, 1+(a+b)/2, b, i, j, l, r);
}
pii ans[MN];
void fin(int node, int a, int b){
push(tree+node, tree[node].lzl, tree[node].lzr);
if(a != b){
add(tree+node*2, tree[node].lzl, tree[node].lzr);
add(tree+node*2+1, tree[node].lzl, tree[node].lzr);
} else{
ans[a] = {tree[node].l, tree[node].r};
return;
}
fin(node*2, a, (a+b)/2);
fin(node*2+1, 1+(a+b)/2, b);
}
void pr(int node, int a, int b){
cout << node << " " << a << " " << b << " " << tree[node].l << " " << tree[node].r << " " << tree[node].lzl << " " << tree[node].lzr << "\n";
if(a != b){pr(node*2, a, (a+b)/2); pr(node*2+1, 1+(a+b)/2, b);}
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
F0R(i, k){
if(op[i] == 1){
upd(1, 1, n, left[i]+1, right[i]+1, height[i], INF);
} else{
upd(1, 1, n, left[i]+1, right[i]+1, -INF, height[i]);
}
//pr(1, 1, n);
//cout << "\n\n";
}
fin(1, 1, n);
F0R(i, n){
finalHeight[i] = max(0, ans[i+1].f);
}
}
/*int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, k;
cin >> n >> k;
int op[k], left[k], right[k], height[k], finalHeight[n];
F0R(i, k) cin >> op[i] >> left[i] >> right[i] >> height[i];
buildWall(n, k, op, left, right, height, finalHeight);
F0R(i, n) cout << finalHeight[i] << " ";
cout << "\n";
return 0;
}*/
Compilation message
wall.cpp: In constructor 'Node::Node()':
wall.cpp:26:12: warning: 'Node::r' will be initialized after [-Wreorder]
int l, r;
^
wall.cpp:25:9: warning: 'int Node::lzl' [-Wreorder]
int lzl, lzr;
^~~
wall.cpp:27:5: warning: when initialized here [-Wreorder]
Node() : l(-INF), r(INF), lzl(-INF), lzr(INF) {}
^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1920 KB |
Output is correct |
2 |
Correct |
7 ms |
2048 KB |
Output is correct |
3 |
Correct |
7 ms |
1920 KB |
Output is correct |
4 |
Correct |
12 ms |
2176 KB |
Output is correct |
5 |
Correct |
11 ms |
2304 KB |
Output is correct |
6 |
Correct |
12 ms |
2176 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1920 KB |
Output is correct |
2 |
Correct |
184 ms |
15496 KB |
Output is correct |
3 |
Correct |
259 ms |
9292 KB |
Output is correct |
4 |
Runtime error |
228 ms |
29048 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1920 KB |
Output is correct |
2 |
Correct |
7 ms |
2048 KB |
Output is correct |
3 |
Correct |
7 ms |
1920 KB |
Output is correct |
4 |
Correct |
13 ms |
2304 KB |
Output is correct |
5 |
Correct |
11 ms |
2304 KB |
Output is correct |
6 |
Correct |
11 ms |
2304 KB |
Output is correct |
7 |
Correct |
5 ms |
1920 KB |
Output is correct |
8 |
Correct |
186 ms |
15480 KB |
Output is correct |
9 |
Correct |
252 ms |
9208 KB |
Output is correct |
10 |
Runtime error |
229 ms |
29048 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1920 KB |
Output is correct |
2 |
Correct |
7 ms |
2048 KB |
Output is correct |
3 |
Correct |
7 ms |
1920 KB |
Output is correct |
4 |
Correct |
15 ms |
2304 KB |
Output is correct |
5 |
Correct |
11 ms |
2176 KB |
Output is correct |
6 |
Correct |
11 ms |
2176 KB |
Output is correct |
7 |
Correct |
6 ms |
1920 KB |
Output is correct |
8 |
Correct |
180 ms |
15480 KB |
Output is correct |
9 |
Correct |
246 ms |
9336 KB |
Output is correct |
10 |
Runtime error |
234 ms |
29176 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
11 |
Halted |
0 ms |
0 KB |
- |