Page 1 of 1

judge not compiling well

Posted: Fri Feb 03, 2006 6:23 pm
by trulo17

Code: Select all

#include<cstdio>
#include<iostream>
#include<deque>
#include<cctype>
#include<cstdlib>
#include<vector>
#include<map>
#include<algorithm>
#include<cstring>
#include<queue>
#include<string>
#include<set>
#include<sstream>
#include<cmath>
#define inf 2000000000
using namespace std;
struct cosa
{
    int p,w;
};
struct cell
{
    int x,y;
};
struct orden
{
    bool operator()(cell a,cell b)
    {
        if(a.x<b.x||(a.x==b.x&&a.y<b.y))
            return true;
        return false;
    }
};
set<cell,orden> S;
int T[1001][31];
cosa A[1001];
int memo(int x,int y)
{    
    cell aux;
    aux.x=x;
    aux.y=y;
    if(S.find(aux)==S.end())
    {
        if(x==0||y==0)
            T[x][y]=0;
        else
        {
            if(A[x].w>y)
                T[x][y]=memo(x-1,y);
            else
                T[x][y]=max(memo(x-1,y),memo(x-1,y-A[x].w)+A[x].p);
        }
        S.insert(aux);
    }
    return T[x][y];
}
int main()
{
    int Test,test,n,m,i,j,k,total,x;
    scanf("%d",&Test);
    for(test=0;test<Test;++test)
    {
        scanf("%d",&n);
        for(i=1;i<=n;++i)
            scanf("%d%d",&A[i].p,&A[i].w);
        scanf("%d",&m);
        for(i=0,total=0;i<m;++i)
        {
            scanf("%d",&x);
            S.clear();
            total+=memo(n,x);
        }
        printf("%d\n",total);
    }
}
the code above is getting compile error, but it's compiling well at home and even in other judges!(i sent the code just to see if it compile and there was no problem).
I discovered that this line:

Code: Select all

if(S.find(aux)==S.end())
it's the reason for the compile error(i removed it and it got wa), but i dont' know why this is happening, i've used set.find() here before(with S.find(int),S.find(string),etc) but since i'm defining the struct, there should no be problem.thx in advance

Posted: Fri Feb 03, 2006 7:33 pm
by Krzysztof Duleba
operator() in orden should be const.