Submission #28804

# Submission time Handle Problem Language Result Execution time Memory
28804 2017-07-17T08:37:12 Z kavun Tropical Garden (IOI11_garden) C++14
Compilation error
0 ms 0 KB
#include "garden.h"
#include "gardenlib.h"
#include <bits/stdc++.h>

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][i].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: In function 'int dfs(int, int, int, int)':
garden.cpp:14:27: error: 'i' was not declared in this scope
         return dfs(adj[v][i].first,d+1,k,v);
                           ^
garden.cpp:19:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i = 0; i < adj[v].size(); i++)
                        ~~^~~~~~~~~~~~~~~
garden.cpp: In function 'void count_routes(int, int, int, int (*)[2], int, int*)':
garden.cpp:45:22: error: 'n' was not declared in this scope
   for(int i = 0; i < n; i++)
                      ^