답안 #878426

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
878426 2023-11-24T10:48:18 Z Husayn 벽 (IOI14_wall) C++14
0 / 100
3 ms 860 KB
#include "wall.h"
#include <bits/stdc++.h>
#define ADD 1
using namespace std;
int const maxn = 2e6 + 9;
int N;
pair<int, int> t[maxn << 2];
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);
		}
	}
	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 = min(t[v << 1].second, t[v << 1 | 1].second);
}
 
void rebuild(int v, int tl, int tr, int finalHeight[]){
    if(tl >= N) return;
	if (tl == tr){
		finalHeight[tl] = t[v].first;
		return;
	}
	push(v);
	int tm = tl + tr >> 1;
	rebuild(v << 1, tl, tm, finalHeight);
	rebuild(v << 1 | 1, tm + 1, tr, finalHeight);
}
 
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 - 1, _left[i], _right[i], height[i], op[i]);
	rebuild(1, 0, maxn - 1, finalHeight);
}

Compilation message

wall.cpp: In function 'void update(int, int, int, int, int, int, int)':
wall.cpp:25:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   25 |  int tm = tl + tr >> 1;
      |           ~~~^~~~
wall.cpp: In function 'void rebuild(int, int, int, int*)':
wall.cpp:39:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   39 |  int tm = tl + tr >> 1;
      |           ~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 600 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 600 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 600 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 860 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -