답안 #737206

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
737206 2023-05-06T20:43:20 Z Boomyday 벽 (IOI14_wall) C++17
컴파일 오류
0 ms 0 KB


#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
//
// Created by adavy on 3/14/2023.
//
//
// Created by adavy on 1/31/2023.
//
// My Header
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;
using db = double;
using str = string; // yay python!

using ii = pair<int,int>;
using pl = pair<ll,ll>;
using pd = pair<db,db>;

using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<ll>;
using vd = vector<db>;
using vs = vector<str>;
using vii = vector<ii>;
using vpl = vector<pl>;
using vpd = vector<pd>;

#define tcT template<class T
#define tcTU tcT, class U

tcT> using V = vector<T>;
tcT, size_t SZ> using AR = array<T,SZ>;
tcT> using PR = pair<T,T>;

// pairs
#define mp make_pair
#define f first
#define s second



#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

#define len(x) int((x).size())
#define bg(x) begin(x)
#define all(x) bg(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define sor(x) sort(all(x))
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pb push_back
#define eb emplace_back
#define pf push_front

const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5;
const ll INF = 1e18; // not too close to LLONG_MAX
const ld PI = acos((ld)-1);
const int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1}; // for every grid problem!!







struct nd{
    ll mn=0,  mx=INF;
    nd(){};
    nd(ll mn, ll mx){
        this->mn = mn; this->mx = mx;
    }
    void operator+=(const nd& other){
        this->mn = min(max(this->mn, other.mn),other.mx);
        this->mx = min(max(this->mx, other.mn),other.mx);
    }
};

void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){

    ll segsize = floor(1<<(int)(log2(n)+1));
    //cout << segsize << endl;
    vector<nd> seg(2*segsize);

    function<void(int, int, int)> pushdown = [&](int rt, int tl, int tr){
        if (tl != tr){
            seg[2*rt] += seg[rt]; seg[2*rt+1] += seg[rt]; seg[rt] = nd();
        }
    };

    function<void(nd, int, int, int, int, int)> update
    = [&](nd Nd, int l, int r, int rt, int tl, int tr){
        if (r < tl || l > tr) return;
        if (l==tl && tr==r){seg[rt] += Nd; return;}
        pushdown(rt, tl, tr);
        int tm = (tl+tr)/2;
        update(Nd, l, min(r, tm), 2*rt, tl, tm);
        update(Nd, max(l, tm+1), r, 2*rt+1, tm+1, tr);
    };

    F0R(i, k){
        if (op[i]==1) {
            update(nd(height[i],INF),left[i],right[i],1,0,segsize-1);
        }
        else {
            update(nd(0,height[i]),left[i],right[i],1,0,segsize-1);
        }
    }


    F0R(i, segsize) pushdown(i, 0, segsize-1);
    FOR(i, segsize, segsize+n) finalHeight[i-segsize] = seg[i].mn;

}

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);
    }

    buildWall(n, k, op, left, right, height, finalHeight);

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

    return 0;
}


/*
10 6
1 1 8 4
2 4 9 1
2 3 6 5
1 0 5 3
1 2 2 5
2 6 7 0

 */



Compilation message

/usr/bin/ld: /tmp/ccJ16wHJ.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cciVb2wI.o:wall.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status