답안 #988

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
988 2013-06-06T22:35:17 Z testtest 파일 삭제 (GA3_delete) C++
컴파일 오류
0 ms 0 KB
#include <vector> 
#include <algorithm> 
  
using namespace std; 
const int SZ = 1005; 
const int INF = 987654321; 
  
vector<int> Gph[SZ]; 
vector<int> Que; 
int Table[SZ][SZ], Tmp[SZ]; 
int Parent[SZ], Size[SZ]; 
  
int DeletePlan( int N, int M, int K, int *A, int *B) { 
    int i, j, k; 
  
    for(i = 0; i < N; i++) Gph[ A[i] ].push_back(i + M); 
    for(i = 1; i < M; i++) Gph[ B[i] ].push_back(i); 
      
    int fr = 0, i; Que.push_back(0); 
    while(fr < Que.size()){ 
        int n = Que[fr++]; 
        for(i = 0; i < Gph[n].size(); i++) { 
            int g = Gph[n][i]; 
            Que.push_back(g); Parent[g] = n; 
        } 
    } 
  
    for(i = 0; i < N + M; i++) { 
        Table[i][1] = 1; if(i >= M) Size[i] = 1; 
        for(j = 2; j <= N; j++) Table[i][j] = INF; 
    } 
  
    for(i = (int)Que.size() - 1; i > 0; i--){ 
        int n = Que[i], p = Parent[n]; 
        Size[p] += Size[n]; Table[n][Size[n]] = 1; 
        for(j = 1; j <= Size[p]; j++) Tmp[j] = Table[p][j]; 
        for(j = 1; j <= Size[p]; j++){ 
            for(k = j; k <= Size[p]; k++) Table[p][k] = min(Table[p][k], Tmp[k - j] + Table[n][j]); 
        } 
    } 
  
    int ret = INF; 
    for(i = 0; i < N + M; i++) ret = min(ret, Table[i][K]); 
  
    return ret; 
}

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:19: error: redeclaration of 'int i'
delete.cpp:14: error: 'int i' previously declared here
delete.cpp:20: warning: comparison between signed and unsigned integer expressions
delete.cpp:22: warning: comparison between signed and unsigned integer expressions