답안 #681

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
681 2013-03-01T04:05:09 Z pl0892029 파일 삭제 (GA3_delete) C++
컴파일 오류
0 ms 0 KB
#include <algorithm>
using namespace std;

typedef struct edge
{
    int u,v;
}edge;

bool cmp(edge a,edge b){return a.u<b.u;}

edge arr[30000];
int dp[10001]; 
int n, queue[30000], h,t;
int s[30000], e[30000], p[30000], c[30000], num[30000];

int DeletePlan(int N, int M, int K, int *A, int *B)
{
    int i, tmp, ans=1e9;
    n = h = t = 0;
    for(i=1;i<M;i++)
    {
        s[n]=0, e[n]=0, num[n]=0;
        p[i]=B[i];
        arr[n].u=B[i],arr[n].v=i;
        n++;
    }
    for(i=0;i<N;i++)
    {
        s[n]=0, e[n]=0, num[n]=0;
        p[i+M]=A[i], num[i+M]=1;
        arr[n].u=A[i],arr[n].v=i+M;
        n++;
    }
    sort(arr,arr+n,cmp);
    
    s[0]=0;
    
    for(i=1;i<n;i++)
    {
        e[arr[i-1].u]=i;
        if( arr[i-1].u != arr[i].u ) s[arr[i].u]=i;
    }
    e[arr[n-1].u]=n;
    
    queue[t++]=0;
    while(h<t)
    {
        tmp = queue[h++];
        while(s[tmp]<e[tmp])
        {
            queue[t++]=arr[s[tmp]].v;
            s[tmp]++;
            c[tmp]++;
        }
    }
    while(--t)
    {
        for(i=K;i>num[queue[t]];i--) if( dp[i-num[queue[t]]>0 || i==num[queue[t]] ) dp[i]=dp[i-num[queue[t]]]-c[queue[t]]+1;
        ans = dp[K]>0 && ans < dp[K] ? ans : dp[K];
    }
    return ans;
}

Compilation message

grader.cpp:30:2: warning: no newline at end of file
delete.cpp: In function 'int DeletePlan(int, int, int, int*, int*)':
delete.cpp:18: warning: converting to 'int' from 'double'
delete.cpp:58: error: expected `]' before ')' token