답안 #878442

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
878442 2023-11-24T11:22:58 Z Husayn 벽 (IOI14_wall) C++14
100 / 100
565 ms 78004 KB
#include "wall.h"
#include <bits/stdc++.h>
#define ADD 1
using namespace std;
int const maxn = 1 << 21;
int N;
pair<int, int> t[(maxn << 2) + 9];
void push(int v){
    t[v << 1].first = min(max(t[v << 1].first, t[v].first), t[v].second);
    t[v << 1 | 1].first = min(max(t[v << 1 | 1].first, t[v].first), t[v].second);
    t[v << 1].second = min(max(t[v << 1].second, t[v].first), t[v].second);
	t[v << 1 | 1].second = min(max(t[v << 1 | 1].second, t[v].first), t[v].second);
}
void update(int v, int tl, int tr, int l, int r, int h, int upd){
	if(l <= tl && tr <= r) {
	    if (upd == ADD){
	        t[v].first = max(t[v].first, h);
	        t[v].second = max(t[v].second, h);
		} else{
	        t[v].first = min(t[v].first, h);
	        t[v].second = min(t[v].second, h);
		}
		return;
	}   
	if(l > tr || r < tl)
	    return;
	push(v);
	int tm = tl + tr >> 1;
	update(v << 1, tl, tm, l, r, h, upd);
	update(v << 1 | 1, tm + 1, tr, l, r, h, upd);
	
    t[v].first = min(t[v << 1].first, t[v << 1 | 1].first);
    t[v].second = max(t[v << 1].second, t[v << 1 | 1].second);
}
int res[maxn];
void rebuild(int v, int tl, int tr){
	if (tl == tr){
		res[tl] = t[v].first;
		return;
	}
	push(v);
	int tm = tl + tr >> 1;
	rebuild(v << 1, tl, tm);
	rebuild(v << 1 | 1, tm + 1, tr);
}
 
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
    N = n;
	for (int i = 0; i < k; i++)
	    update(1, 0, maxn, left[i], right[i], height[i], op[i]);
	rebuild(1, 0, maxn);
	for(int i = 0; i < n; i ++)
	    finalHeight[i] = res[i];
	 
}

Compilation message

wall.cpp: In function 'void update(int, int, int, int, int, int, int)':
wall.cpp:28:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   28 |  int tm = tl + tr >> 1;
      |           ~~~^~~~
wall.cpp: In function 'void rebuild(int, int, int)':
wall.cpp:42:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   42 |  int tm = tl + tr >> 1;
      |           ~~~^~~~
wall.cpp: In function 'void buildWall(int, int, int*, int*, int*, int*, int*)':
wall.cpp:38:9: warning: array subscript 2097152 is above array bounds of 'int [2097152]' [-Warray-bounds]
   38 |   res[tl] = t[v].first;
      |   ~~~~~~^
wall.cpp:35:5: note: while referencing 'res'
   35 | int res[maxn];
      |     ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 41300 KB Output is correct
2 Correct 28 ms 41556 KB Output is correct
3 Correct 28 ms 41468 KB Output is correct
4 Correct 30 ms 41556 KB Output is correct
5 Correct 29 ms 41556 KB Output is correct
6 Correct 30 ms 41556 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 41308 KB Output is correct
2 Correct 260 ms 55144 KB Output is correct
3 Correct 174 ms 48468 KB Output is correct
4 Correct 429 ms 59564 KB Output is correct
5 Correct 292 ms 60496 KB Output is correct
6 Correct 287 ms 59008 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 41248 KB Output is correct
2 Correct 30 ms 41552 KB Output is correct
3 Correct 28 ms 41544 KB Output is correct
4 Correct 31 ms 41564 KB Output is correct
5 Correct 30 ms 41552 KB Output is correct
6 Correct 31 ms 41560 KB Output is correct
7 Correct 27 ms 41308 KB Output is correct
8 Correct 257 ms 55120 KB Output is correct
9 Correct 173 ms 48572 KB Output is correct
10 Correct 419 ms 59468 KB Output is correct
11 Correct 292 ms 60512 KB Output is correct
12 Correct 290 ms 58876 KB Output is correct
13 Correct 29 ms 41300 KB Output is correct
14 Correct 258 ms 54964 KB Output is correct
15 Correct 52 ms 42540 KB Output is correct
16 Correct 427 ms 59744 KB Output is correct
17 Correct 296 ms 59004 KB Output is correct
18 Correct 290 ms 59036 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 41300 KB Output is correct
2 Correct 30 ms 41552 KB Output is correct
3 Correct 29 ms 41512 KB Output is correct
4 Correct 32 ms 41560 KB Output is correct
5 Correct 33 ms 41660 KB Output is correct
6 Correct 31 ms 41556 KB Output is correct
7 Correct 28 ms 41300 KB Output is correct
8 Correct 257 ms 55120 KB Output is correct
9 Correct 172 ms 48528 KB Output is correct
10 Correct 412 ms 59668 KB Output is correct
11 Correct 289 ms 60456 KB Output is correct
12 Correct 286 ms 58964 KB Output is correct
13 Correct 27 ms 41432 KB Output is correct
14 Correct 278 ms 54980 KB Output is correct
15 Correct 50 ms 42576 KB Output is correct
16 Correct 440 ms 59728 KB Output is correct
17 Correct 299 ms 59256 KB Output is correct
18 Correct 290 ms 58960 KB Output is correct
19 Correct 545 ms 77908 KB Output is correct
20 Correct 535 ms 75476 KB Output is correct
21 Correct 541 ms 77736 KB Output is correct
22 Correct 540 ms 75340 KB Output is correct
23 Correct 531 ms 75324 KB Output is correct
24 Correct 530 ms 75192 KB Output is correct
25 Correct 549 ms 75184 KB Output is correct
26 Correct 542 ms 77700 KB Output is correct
27 Correct 539 ms 78004 KB Output is correct
28 Correct 527 ms 75088 KB Output is correct
29 Correct 556 ms 75344 KB Output is correct
30 Correct 565 ms 75208 KB Output is correct