Submission #587158

#TimeUsernameProblemLanguageResultExecution timeMemory
587158FatihSolakGame (IOI13_game)C++17
Compilation error
0 ms0 KiB
#include "game.h"
#include <bits/stdc++.h>
#define CNT 8e7
#define CNT2 3e5
using namespace std;
long long gcd2(long long X, long long Y) {
    long long tmp;
    while (X != Y && Y != 0) {
        tmp = X;
        X = Y;
        Y = tmp % Y;
    }
    return X;
}
struct node{
    int l = 0,r = 0;
    long long val = 0;
}nodes[CNT];
int cnt = 1;
struct SegTree{
    int root = -1;
    int n = 1e9;
    void upd(int v,int tl,int tr,int pos,long long val){
        if(tl == tr){
            nodes[v].val = val;
            return;
        }
        int tm = (tl + tr)/2;
        if(pos <= tm){
            if(nodes[v].l == 0)
                nodes[v].l = cnt++;
            upd(nodes[v].l,tl,tm,pos,val);
        }
        else{
            if(nodes[v].r == 0)
                nodes[v].r = cnt++;
            upd(nodes[v].r,tm+1,tr,pos,val);
        }
        nodes[v].val = gcd2(nodes[nodes[v].l].val,nodes[nodes[v].r].val);
    }
    long long get(int v,int tl,int tr,int l,int r){
        if(v == 0 || tr < l || r < tl)
            return 0;
        if(l <= tl && tr <= r){
            return nodes[v].val;
        }
        int tm = (tl + tr)/2;
        return gcd2(get(nodes[v].l,tl,tm,l,r),get(nodes[v].r,tm+1,tr,l,r));
    }
    void upd(int pos,long long val){
        if(root == -1)
            root = cnt++;
        upd(root,1,n,pos,val);
    }
    long long get(int l,int r){
        if(root == -1)
            root = cnt++;
        return get(root,1,n,l,r);
    }
};
struct node2{
    int l = 0,r = 0;
    SegTree val;
    map<int,SegTree> numbers;
}nodes2[CNT2];
int cnt2 = 1;
struct SegTree2D{
    int root = -1;
    int n = 1e9;
    int m = 1e9;
    void upd(int v,int tl,int tr,int x,int y,long long val){
        nodes2[v].numbers[y].upd(x,val);
        nodes2[v].val.upd(y,nodes2[v].numbers[y].get(tl,tr));
        if(tl == tr){
            return;
        }
        int tm = (tl + tr)/2;
        if(x <= tm){
            if(nodes2[v].l == 0)
                nodes2[v].l = cnt2++;
            upd(nodes2[v].l,tl,tm,x,y,val);
        }
        else{
            if(nodes2[v].r == 0)
                nodes2[v].r = cnt2++;
            upd(nodes2[v].r,tm+1,tr,x,y,val);
        }
    }
    long long get(int v,int tl,int tr,int l,int r,int l2,int r2){
        if(v == 0 || tr < l || r < tl)
            return 0;
        if(l <= tl && tr <= r){
            return nodes2[v].val.get(l2,r2);
        }
        int tm = (tl + tr)/2;
        return gcd2(get(nodes2[v].l,tl,tm,l,r,l2,r2),get(nodes2[v].r,tm+1,tr,l,r,l2,r2));
    }
    void upd(int x,int y,long long val){
        if(root == -1)
            root = cnt2++;
        upd(root,1,n,x,y,val);
    }
    long long get(int l,int r,int l2,int r2){
        if(root == -1)
            root = cnt2++;
        return get(root,1,n,l,r,l2,r2);
    }
}tree;
void init(int R, int C) {
    //tree.init(R,C);
}

void update(int P, int Q, long long K) {
    P++,Q++;
    tree.upd(P,Q,K);
}

long long calculate(int P, int Q, int U, int V) {
    P++,Q++,U++,V++;
    //assert(cnt < CNT);
    //assert(cnt2 < CNT2);
    return tree.get(P,U,Q,V);
}

Compilation message (stderr)

game.cpp:3:13: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
    3 | #define CNT 8e7
      |             ^~~
game.cpp:18:8: note: in expansion of macro 'CNT'
   18 | }nodes[CNT];
      |        ^~~
game.cpp:3:13: error: could not convert '8.0e+7' from 'double' to 'long unsigned int'
    3 | #define CNT 8e7
      |             ^~~
game.cpp:18:8: note: in expansion of macro 'CNT'
   18 | }nodes[CNT];
      |        ^~~
game.cpp:3:13: error: size of array 'nodes' has non-integral type 'double'
    3 | #define CNT 8e7
      |             ^~~
game.cpp:18:8: note: in expansion of macro 'CNT'
   18 | }nodes[CNT];
      |        ^~~
game.cpp:4:14: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
    4 | #define CNT2 3e5
      |              ^~~
game.cpp:65:9: note: in expansion of macro 'CNT2'
   65 | }nodes2[CNT2];
      |         ^~~~
game.cpp:4:14: error: could not convert '3.0e+5' from 'double' to 'long unsigned int'
    4 | #define CNT2 3e5
      |              ^~~
game.cpp:65:9: note: in expansion of macro 'CNT2'
   65 | }nodes2[CNT2];
      |         ^~~~
game.cpp:4:14: error: size of array 'nodes2' has non-integral type 'double'
    4 | #define CNT2 3e5
      |              ^~~
game.cpp:65:9: note: in expansion of macro 'CNT2'
   65 | }nodes2[CNT2];
      |         ^~~~