답안 #879255

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
879255 2023-11-27T04:37:30 Z marcid 벽 (IOI14_wall) C++17
100 / 100
560 ms 77648 KB
#include "wall.h"
#include <bits/stdc++.h>
using namespace std;
#define vb vector<bool>
#define vi vector<int>
#define ii pair<int,int>
#define iii tuple<int,int,int>
#define vii vector<ii>
#define viii vector<iii>
#define pb push_back
#define eb emplace_back
#define mod 1000000007
const int maxn = 1<<21;
ii tree[(maxn<<2)+2];

void push(int v) {
	tree[v<<1].first=min(max(tree[v<<1].first,tree[v].first),tree[v].second);
	tree[v<<1|1].first=min(max(tree[v<<1|1].first,tree[v].first),tree[v].second);
	tree[v<<1].second=min(max(tree[v].first,tree[v<<1].second),tree[v].second);
	tree[v<<1|1].second=min(max(tree[v].first,tree[v<<1|1].second),tree[v].second);
}

void update(int t, int l, int r, int x, int v, int tl, int tr) {
	if (tl > r || l > tr) return;
	if (l <= tl && tr <= r) {
		if (t-1) {
			tree[v].first=min(tree[v].first,x);
			tree[v].second=min(tree[v].second,x);
		} else {
			tree[v].first=max(tree[v].first, x);
			tree[v].second=max(tree[v].second,x);
		} return;
	} 
	push(v);
	int mid = tl + tr >> 1;
	update(t,l,r,x,v*2,tl,mid); update(t,l,r,x,v*2+1,mid+1,tr);
	tree[v].first=min(tree[v<<1].first,tree[v<<1|1].first);
	tree[v].second=max(tree[v<<1].second,tree[v<<1|1].second);
}
int fin[maxn];
void build(int v, int tl, int tr) {
	if (tl==tr) {
		fin[tl]=tree[v].first;
		return;
	}
	push(v);
	int mid = tl + tr >> 1;
	build(v*2,tl,mid); build(v*2+1,mid+1,tr);
}

void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]) {
	for (int i = 0; i < k; i++) {
		update(op[i],left[i],right[i],height[i],1,0,n+10);
	} build(1,0,n+10); for (int i = 0; i < n; i++) finalHeight[i]=fin[i];
}

Compilation message

wall.cpp: In function 'void update(int, int, int, int, int, int, int)':
wall.cpp:35:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   35 |  int mid = tl + tr >> 1;
      |            ~~~^~~~
wall.cpp: In function 'void build(int, int, int)':
wall.cpp:47:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   47 |  int mid = tl + tr >> 1;
      |            ~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 3 ms 576 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 4 ms 860 KB Output is correct
5 Correct 4 ms 968 KB Output is correct
6 Correct 4 ms 900 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 135 ms 14108 KB Output is correct
3 Correct 137 ms 8116 KB Output is correct
4 Correct 378 ms 22608 KB Output is correct
5 Correct 238 ms 23560 KB Output is correct
6 Correct 237 ms 22100 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 2 ms 452 KB Output is correct
3 Correct 2 ms 604 KB Output is correct
4 Correct 4 ms 860 KB Output is correct
5 Correct 4 ms 860 KB Output is correct
6 Correct 4 ms 904 KB Output is correct
7 Correct 0 ms 444 KB Output is correct
8 Correct 133 ms 14028 KB Output is correct
9 Correct 138 ms 8044 KB Output is correct
10 Correct 392 ms 22868 KB Output is correct
11 Correct 238 ms 23632 KB Output is correct
12 Correct 241 ms 22432 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 142 ms 13940 KB Output is correct
15 Correct 22 ms 2132 KB Output is correct
16 Correct 402 ms 23120 KB Output is correct
17 Correct 240 ms 22272 KB Output is correct
18 Correct 245 ms 22432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 4 ms 860 KB Output is correct
5 Correct 4 ms 860 KB Output is correct
6 Correct 4 ms 880 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 130 ms 13904 KB Output is correct
9 Correct 147 ms 8000 KB Output is correct
10 Correct 396 ms 22608 KB Output is correct
11 Correct 243 ms 23636 KB Output is correct
12 Correct 237 ms 21992 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 131 ms 13948 KB Output is correct
15 Correct 24 ms 2132 KB Output is correct
16 Correct 386 ms 23008 KB Output is correct
17 Correct 281 ms 22256 KB Output is correct
18 Correct 240 ms 22352 KB Output is correct
19 Correct 556 ms 77648 KB Output is correct
20 Correct 527 ms 75032 KB Output is correct
21 Correct 546 ms 77404 KB Output is correct
22 Correct 527 ms 74972 KB Output is correct
23 Correct 534 ms 74836 KB Output is correct
24 Correct 544 ms 74744 KB Output is correct
25 Correct 527 ms 74832 KB Output is correct
26 Correct 535 ms 77328 KB Output is correct
27 Correct 560 ms 77312 KB Output is correct
28 Correct 534 ms 74836 KB Output is correct
29 Correct 529 ms 74832 KB Output is correct
30 Correct 532 ms 74832 KB Output is correct