ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1078. Segments

compilation error
Posted by huiqi xu 24 Apr 2007 11:22
why did i get compilation error? here is my program:
<#include<iostream>
using namespace std;
#define N 500
int num;
int denote[N],c[N],len[N];
int length;
void quick_sort(int st[N][2],int low,int high,int pi);
void print()
{
    int mem[N][2];
    int k=1;
    for(int i=1;i<=num;i++)
        if(c[i]==1)
        {
            mem[k][0]=len[i];
            mem[k][1]=i;
            k++;
        }
        quick_sort(mem,1,k-1,1);
        if(k==1)
            cout<<1<<endl;
        else
        {
            for(i=1;i<=k-1;i++)
                cout<<mem[i][1]<<' ';
            cout<<endl;
        }
}
void quick_sort(int st[N][2],int low,int high,int pi)
{
    int head=low,tail=high;
    st[0][0]=st[pi][0];
    st[0][1]=st[pi][1];
    if(low>=high)
        ;
    else
    {
        while(low<high)
        {
            while(low<high&&st[high][0]>=st[0][0])  high--;
            st[low][0]=st[high][0];
            st[low][1]=st[high][1];
            while(low<high&&st[low][0]<st[0][0])  low++;
            st[high][0]=st[low][0];
            st[high][1]=st[low][1];
        }
        st[low][0]=st[0][0];
        st[low][1]=st[0][1];
        quick_sort(st,head,low-1,head);
        quick_sort(st,high+1,tail,high+1);
    }
}
int main()
{
    int lp[N][2],rp[N];
    int i,j,k=1;
    cin>>num;
    for(i=1;i<=num;i++)
    {
        cin>>lp[i][0]>>rp[i];
        len[i]=rp[i]-lp[i][0];
        lp[i][1]=i;
    }
    memset(c,0,sizeof(c));
    quick_sort(lp,1,num,1);
    length=1;
    denote[num]=1;
    for(i=num-1;i>0;i--)
    {
        denote[i]=1;
        for(j=i+1;j<=num;j++)
        {
            if(lp[i][0]!=lp[j][0])
                if(rp[lp[i][1]]>rp[lp[j][1]])
                    if(denote[i]<denote[j]+1)
                    {
                        denote[i]=denote[j]+1;
                        if(length<denote[i])
                        {
                            c[lp[i][1]]=1;
                            if(length==1) c[lp[j][1]]=1;
                            length=denote[i];
                        }
                    }
        }
    }
    cout<<length<<endl;
    print();
    return 0;
}



Edited by author 24.04.2007 11:29
Re: compilation error
Posted by Romko [Lviv NU] 24 Apr 2007 11:45
First write #include <iostream> instead of <#include <iosteream>
Second declar indentifier i in for(int i=1;i<=num;i++)
{
...
}
instead of
for(i=1;i<=num;i++)
{
...
}
Re: compilation error
Posted by huiqi xu 24 Apr 2007 21:05
the first you mentioned is my mistaken writing when i am editing.the second is the reason i get CE.thank you so much.
Re: compilation error
Posted by Romko [Lviv NU] 25 Apr 2007 00:01
You're welcome :)