답안 #930154

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
930154 2024-02-18T17:54:28 Z FanOfWilliamLin 벽 (IOI14_wall) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;

const int N = 2e6 + 5;
struct node {
  int up = 0, down = 1e5 + 5;
  node() {}
}
d[4 * N];
void apply(int ind, int up, int down) {
  if (ind >= 0 && ind < 4 * N) {
	d[ind].down = min(d[ind].down, down);
	d[ind].down = max(d[ind].down, up);
	d[ind].up = max(d[ind].up, up);
	d[ind].up = min(d[ind].up, down);
  }
}
void range_modify(int mode, int ml, int mr, int val, int ind = 1, int l = 0, int r = N - 1) {
  if (ml > r || mr < l) return;
  if (ml <= l && mr >= r) {
	if (mode) {
	  d[ind].down = min(d[ind].down, val);
	  d[ind].up = min(d[ind].up, val);
	} else {
	  d[ind].down = max(d[ind].down, val);
	  d[ind].up = max(d[ind].up, val);
	}
	return;
  }
  int mid = (l + r) / 2;
  apply(ind << 1, d[ind].up, d[ind].down);
  apply(ind << 1 | 1, d[ind].up, d[ind].down);
  d[ind].up = 0, d[ind].down = 1e5 + 5;
  range_modify(mode, ml, mr, val, ind << 1, l, mid);
  range_modify(mode, ml, mr, val, ind << 1 | 1, mid + 1, r);
}
int n, k;
void query(int ind, int l, int r) {
  if (l == r) {
	if (l != n) cout << min(d[ind].up, d[ind].down) << "\n";
	return;
  }
  apply(ind << 1, d[ind].up, d[ind].down);
  apply(ind << 1 | 1, d[ind].up, d[ind].down);
  d[ind].up = 0, d[ind].down = 1e5 + 5;
  int mid = l + r >> 1;
  query(ind << 1, l, mid);
  query(ind << 1 | 1, mid + 1, r);
}

signed main() {
  fastio
  cin >> n >> k;
  while (k--) {
	int mode, l, r, val;
	cin >> mode >> l >> r >> val;
	range_modify(mode - 1, l, r, val, 1, 0, n);
  }
  query(1, 0, n);
}

Compilation message

wall.cpp: In function 'void query(int, int, int)':
wall.cpp:49:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   49 |   int mid = l + r >> 1;
      |             ~~^~~
/usr/bin/ld: /tmp/ccqjfjqN.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccqF6srO.o:wall.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccqjfjqN.o: in function `main':
grader.cpp:(.text.startup+0x133): undefined reference to `buildWall(int, int, int*, int*, int*, int*, int*)'
collect2: error: ld returned 1 exit status