Submission #6162

# Submission time Handle Problem Language Result Execution time Memory
6162 2014-06-22T15:52:40 Z baneling100 파일 삭제 (GA3_delete) C++
15 / 120
148 ms 1940 KB
#include <vector>
#define INF 0x7ffffff

using namespace std;

vector <int> X[13000];
vector <int> LEV[3001];
int D[10001], Cnt[13000];

void DFS(int now, int lev)
{
    int i, j=X[now].size();

    LEV[lev].push_back(now);
    for(i=0 ; i<j ; i++)
    {
        DFS(X[now][i],lev+1);
        Cnt[now]+=Cnt[X[now][i]];
    }
}

int DeletePlan( int N, int M, int K, int *A, int *B)
{
    int i, j, k, l;

    for(i=0 ; i<N ; i++)
    {
        X[A[i]+N].push_back(i);
        Cnt[i]=1;
        D[i+1]=INF;
    }
    for(i=1 ; i<M ; i++)
        X[B[i]+N].push_back(i+N);
    DFS(N,0);
    for(i=0 ; i<=M ; i++)
    {
        k=LEV[i].size();
        for(j=0 ; j<k ; j++)
        {
            for(l=N ; l>=Cnt[LEV[i][j]] ; l--)
                    if(D[l]>D[l-Cnt[LEV[i][j]]]+1)
                        D[l]=D[l-Cnt[LEV[i][j]]]+1;
        }
    }
    return D[K];
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1676 KB Output is correct
2 Correct 0 ms 1676 KB Output is correct
3 Correct 0 ms 1676 KB Output is correct
4 Correct 0 ms 1676 KB Output is correct
5 Correct 0 ms 1676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1676 KB Output is correct
2 Incorrect 0 ms 1676 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1676 KB Output is correct
2 Correct 4 ms 1676 KB Output is correct
3 Correct 8 ms 1676 KB Output is correct
4 Correct 8 ms 1676 KB Output is correct
5 Correct 4 ms 1676 KB Output is correct
6 Correct 8 ms 1676 KB Output is correct
7 Incorrect 4 ms 1676 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 140 ms 1808 KB Output is correct
2 Correct 148 ms 1940 KB Output is correct
3 Incorrect 148 ms 1808 KB Output isn't correct
4 Halted 0 ms 0 KB -