Submission #155263

# Submission time Handle Problem Language Result Execution time Memory
155263 2019-09-27T11:36:40 Z mhy908 Land of the Rainbow Gold (APIO17_rainbow) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define llinf 8987654321987654321
#define inf 1987654321
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
struct DYNAMIC_SEGMENT_TREE {
    struct NODE {
        int st, fin;
        int l, r;
        LL sum;
        NODE(){sum=0;l=0;r=0;}
    };
    vector<NODE> tree;
    int newNode(int a, int b) {
        NODE temp;
        temp.st=a;
        temp.fin=b;
        tree.push_back(temp);
        return tree.size()-1;
    }
    void in_DST(int point, int num, LL p, bool strong) {
        NODE here=tree[point];
        if(here.st==here.fin){
            if(strong)here.sum=p;
            else here.sum+=p;
            tree[point]=here;
            return;
        }
        int mid=(here.st+here.fin)/2;
        if(!here.l)here.l=newNode(here.st, mid);
        if(!here.r)here.r=newNode(mid+1, here.fin);
        if(num<=mid)in_DST(here.l, num, p, strong);
        else in_DST(here.r, num, p, strong);
        here.sum=tree[here.l].sum+tree[here.r].sum;
        tree[point]=here;
    }
    LL sumrange(int point, int a, int b){
        if(tree[point].st>=a&&tree[point].fin<=b)
            return tree[point].sum;
        if(tree[point].st>b||tree[point].fin<a||tree[point].sum==0)
            return 0;
        return sumrange(tree[point].l, a, b)+sumrange(tree[point].r, a, b);
    }
    DYNAMIC_SEGMENT_TREE(){newNode(1, 500000);}
    void update(int num, LL p, bool strong){
        in_DST(0, num, p, strong);
    }
    LL get_sum(int a, int b){
        return sumrange(0, a, b);
    }
};
struct TWO_DIMENSIONAL_SEGMENT_TREE
{
    struct NODE {
        int st, fin;
        int l, r;
        DYNAMIC_SEGMENT_TREE dst;
        LL sum;
        NODE(){l=0;r=0;sum=0;}
    };
    vector<NODE> tree;
    int newNode(int a, int b) {
        NODE temp;
        temp.st=a;
        temp.fin=b;
        tree.push_back(temp);
        return tree.size()-1;
    }
    void in_DST(int point, int numx, int numy, LL p) {
        //printf("%d %d %d %lld %d %d\n", point, numx, numy, p, tree[point].st, tree[point].fin);
        if(tree[point].st==tree[point].fin){
            tree[point].dst.update(numy, p, true);
            return;
        }
        int mid=(tree[point].st+tree[point].fin)/2;
        if(!tree[point].l)tree[point].l=newNode(tree[point].st, mid);
        if(!tree[point].r)tree[point].r=newNode(mid+1, tree[point].fin);
        if(numx<=mid)in_DST(tree[point].l, numx, numy, p);
        else in_DST(tree[point].r, numx, numy, p);
        tree[point].sum+=p;
        tree[point].dst.update(numy, p, false);
    }
    LL sumrange(int point, int ax, int ay, int bx, int by){
        //printf("%d %d %d %d %d\n", point, ax, bx, tree[point].st, tree[point].fin);
        if(tree[point].st>=ax&&tree[point].fin<=bx)
            return tree[point].dst.get_sum(ay, by);
        if(tree[point].st>bx||tree[point].fin<ax||tree[point].sum==0)
            return 0;
        return tree[point].l?sumrange(tree[point].l, ax, ay, bx, by):0+tree[point].r?sumrange(tree[point].r, ax, ay, bx, by):0;
    }
    TWO_DIMENSIONAL_SEGMENT_TREE() {newNode(1, 500000);}
    void update(int numx, int numy, LL p){
        in_DST(0, numx, numy, p);
    }
    LL get_sum(int a, int b, int c, int d){
        return sumrange(0, a, b, c, d);
    }
}seg;

Compilation message

/tmp/ccKCsItF.o: In function `main':
grader.cpp:(.text.startup+0xcc): undefined reference to `init(int, int, int, int, int, char*)'
grader.cpp:(.text.startup+0x131): undefined reference to `colour(int, int, int, int)'
collect2: error: ld returned 1 exit status