답안 #121941

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
121941 2019-06-27T08:55:49 Z SOIVIEONE 벽 (IOI14_wall) C++14
컴파일 오류
0 ms 0 KB
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>

#include "wall.h"



#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 2222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
vector<pair<ll, pll> > adl[N], adr[N], reml[N], remr[N];

int *arr, nn;
pii t[N << 2];

void push(int v, int op, int val)
{
	if(op == 1)
		umax(t[v].F, val), umax(t[v].S, val);
	else
		umin(t[v].F, val), umin(t[v].S, val);
	return;
}

void up(int foo, int hoo, int op, int val, int v = 1, int l = 1, int r = nn)
{
	if(l > hoo || r < foo)
		return;
	if(l >= foo && r <= hoo)
	{
		push(v, op, val);
		return;
	}
	push(v << 1, 1, t[v].F);
	push(v << 1 | 1, 1, t[v].F);
	push(v << 1, 2, t[v].S);
	push(v << 1 | 1, 2, t[v].S);	
	t[v].F = 0; t[v].S = 1e5;
	int m = (l + r) >> 1;
	up(foo, hoo, op, val, v << 1, l, m);
	up(foo, hoo, op, val, v << 1 | 1, m + 1, r);
}
int *a;
void build(int v = 1, int l = 1, int r = nn)
{
	if(l == r)
	{
		a[l-1] = t[v].F;
		return;
	}
	push(v << 1, 1, t[v].F);
	push(v << 1 | 1, 1, t[v].F);
	push(v << 1, 2, t[v].S);
	push(v << 1 | 1, 2, t[v].S);	
	t[v].F = 0; t[v].S = 1e5;
	int m = (l + r) >> 1;
	build(v << 1, l, m);
	build(v << 1 | 1, m + 1, r);
}

void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[])
{
	nn = n;
	a = finalHeight;
	for(int i = 0; i <= n; i ++)
		t[i] = M(0, 1e5);
	for(int i = 0; i < k; i ++)
		up(left[i] + 1, right[i] + 1, op[i], height[i]);
	build();
}

int main()
{
  int n;
  int k;

  int i, j;  
  int status = 0;

  status = scanf("%d%d", &n, &k);
  assert(status == 2);

  int* op = (int*)calloc(sizeof(int), k);
  int* left = (int*)calloc(sizeof(int), k);
  int* right = (int*)calloc(sizeof(int), k);
  int* height = (int*)calloc(sizeof(int), k);
  int* finalHeight = (int*)calloc(sizeof(int), n);

  for (i = 0; i < k; i++){
    status = scanf("%d%d%d%d", &op[i], &left[i], &right[i], &height[i]);
    assert(status == 4);
  }
cout << "kkk";
  buildWall(n, k, op, left, right, height, finalHeight);

  for (j = 0; j < n; j++)
    printf("%d\n", finalHeight[j]);
  
  return 0;
}

Compilation message

/tmp/ccERBO9S.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccWCR5Tc.o:wall.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status