답안 #28805

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
28805 2017-07-17T08:39:13 Z kavun 열대 식물원 (Tropical Garden) (IOI11_garden) C++14
컴파일 오류
0 ms 0 KB
using namespace std;
vector <pair<int,int> > adj[2000];

int dfs(int v, int d, int k, int par)
{
    if(d == k)
        return v;

    if(adj[v].size() == 1)
        return dfs(adj[v][0].first,d+1,k,v);
    else
    {
        int mx = 0;
        int mxver;
        for(int i = 0; i < adj[v].size(); i++)
        {
            int u = adj[v][i].first;
            int bt = adj[v][i].second;
            if(u != par)
            {
                if(bt > mx)
                {
                    mx = bt;
                    mxver = u;
                }
            }
        }
        return dfs(mxver,d+1,k,v);
    }
}

void count_routes(int N, int M, int P, int R[][2], int Q, int G[])
{
  for(int i = 0; i < M; i++)
  {
      int v = R[i][0], u = R[i][1], beauty = M - i;
      adj[v].push_back(make_pair(u,beauty));
      adj[u].push_back(make_pair(v,beauty));
  }
  int res = 0;
  for(int i = 0; i < N; i++)
  {
      if(dfs(i,0,G[0],-1) == P)
        res++;
  }

  for(int i=0; i<Q; i++)
    answer(res);
}

Compilation message

garden.cpp:2:1: error: 'vector' does not name a type
 vector <pair<int,int> > adj[2000];
 ^~~~~~
garden.cpp: In function 'int dfs(int, int, int, int)':
garden.cpp:9:8: error: 'adj' was not declared in this scope
     if(adj[v].size() == 1)
        ^~~
garden.cpp: In function 'void count_routes(int, int, int, int (*)[2], int, int*)':
garden.cpp:37:7: error: 'adj' was not declared in this scope
       adj[v].push_back(make_pair(u,beauty));
       ^~~
garden.cpp:37:24: error: 'make_pair' was not declared in this scope
       adj[v].push_back(make_pair(u,beauty));
                        ^~~~~~~~~
garden.cpp:48:5: error: 'answer' was not declared in this scope
     answer(res);
     ^~~~~~