답안 #29050

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
29050 2017-07-18T07:43:03 Z kavun 악어의 지하 도시 (IOI11_crocodile) C++14
46 / 100
793 ms 262144 KB
#include "crocodile.h"
#include <bits/stdc++.h>

using namespace std;
vector <pair<int,int> > adj[100010];

int dfs(int v, int par)
{
  vector <int> lst;

  if(adj[v].size() == 1)
    return 0;

  for(int i = 0; i < adj[v].size(); i++)
    {
      int u = adj[v][i].first;
      if(u != par)
	{
	  int val = dfs(u,v);
	  int len = adj[v][i].second;
	  lst.push_back(val + len);
	}
    }
  sort(lst.begin(),lst.end());
  return lst[1];
}

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{

  for(int i = 0; i < M ; i++)
    {
      int v = R[i][0],u = R[i][1],l = L[i];
      adj[v].push_back(make_pair(u,l));
      adj[u].push_back(make_pair(v,l));
    }

  for(int i = 0; i < K; i++)
    if(P[i] == 0)
      return 0;

  return dfs(0,0);
}

Compilation message

crocodile.cpp: In function 'int dfs(int, int)':
crocodile.cpp:14:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0; i < adj[v].size(); i++)
                    ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 121748 KB Output is correct
2 Correct 0 ms 121748 KB Output is correct
3 Correct 0 ms 121748 KB Output is correct
4 Correct 0 ms 121748 KB Output is correct
5 Correct 3 ms 121748 KB Output is correct
6 Correct 0 ms 121748 KB Output is correct
7 Correct 0 ms 121748 KB Output is correct
8 Correct 0 ms 121748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Memory limit exceeded 16 ms 262144 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Memory limit exceeded 793 ms 262144 KB Memory limit exceeded
2 Halted 0 ms 0 KB -