Submission #13235

# Submission time Handle Problem Language Result Execution time Memory
13235 2015-02-05T11:42:10 Z dohyun0324 Weighting stones (IZhO11_stones) C++
Compilation error
0 ms 0 KB
#include<stdio.h>
#include<algorithm>
using namespace std;
static int n,x,y,t=1,p;
struct data
{
   static int maxi,mini,ch;
}Tree[600010];
void update(int x,int y,int k,int s,int e)
{
    if(Tree[k].ch!=0)
    {
        Tree[k].maxi+=Tree[k].ch; Tree[k].mini+=Tree[k].ch;
        Tree[k*2].ch+=Tree[k].ch; Tree[k*2+1].ch+=Tree[k].ch; Tree[k].ch=0;
    }
    if(s<=x && y<=e)
    {
        Tree[k].maxi+=p; Tree[k].mini+=p; Tree[k*2].ch+=p; Tree[k*2+1].ch+=p;
        return;
    }
    if(s>y || e<x) return;
    update(x,(x+y)/2,k*2,s,e);
    update((x+y)/2+1,y,k*2+1,s,e);
    Tree[k].maxi=max(Tree[k*2].maxi,Tree[k*2+1].maxi);
    Tree[k].mini=min(Tree[k*2].mini,Tree[k*2+1].mini);
}
int main()
{
    int i;
    scanf("%d",&n);
    for(;;){if(t>=n) break; t*=2;}
    for(i=1;i<=n;i++)
    {
        scanf("%d %d",&x,&y);
        if(y==1) p=1;
        else p=-1;
        update(1,t,1,1,x);
        if(Tree[1].maxi<=0) printf("<\n");
        else if(Tree[1].mini>=0) printf(">\n");
        else printf("?\n");
    }
    return 0;
}

Compilation message

stones.cpp: In function ‘int main()’:
stones.cpp:30:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
                   ^
stones.cpp:34:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d",&x,&y);
                             ^
/tmp/ccxkEdcR.o: In function `update(int, int, int, int, int)':
stones.cpp:(.text+0x53): undefined reference to `data::ch'
stones.cpp:(.text+0x5d): undefined reference to `data::maxi'
stones.cpp:(.text+0x63): undefined reference to `data::mini'
stones.cpp:(.text+0x69): undefined reference to `data::ch'
stones.cpp:(.text+0x83): undefined reference to `data::maxi'
stones.cpp:(.text+0x89): undefined reference to `data::mini'
stones.cpp:(.text+0x91): undefined reference to `data::ch'
/tmp/ccxkEdcR.o: In function `main':
stones.cpp:(.text.startup+0xac): undefined reference to `data::maxi'
stones.cpp:(.text.startup+0xb6): undefined reference to `data::mini'
collect2: error: ld returned 1 exit status