답안 #236291

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
236291 2020-06-01T01:35:37 Z Masterdan 악어의 지하 도시 (IOI11_crocodile) C++14
46 / 100
194 ms 262148 KB
#include "crocodile.h"
#include <bits/stdc++.h>
#define F  first
#define S second
#define pb  push_back
#define MAX 1e9+7
#define MIN -1
#define all(a)  a.begin (), a.end ()
#define mem(a, c)  memset(a, c, sizeof a)
#define mk  make_pair
using namespace std;
typedef vector <int> vi;
typedef pair<int, int> ii;
typedef long long int ll;
typedef vector <ii> vii;
typedef vector<vi> vvi;
typedef double db;
typedef priority_queue<int,vi,  greater<int> > pq;
vector<vii > G;
int hojas[1010], vis[1010];
int solve(int x, int prev){
    vis[x]=1;
    if(hojas[x]==1){
        return 0;
    }
    vi formas;
    for(int i=0;i<G[x].size ();i++){
        ii v=G[x][i];
        int child=v.F, peso=v.S;
        if(child==prev)continue;
        int aux=peso+solve(child, x);
        formas.pb(aux);
    }
    sort(all(formas));
   return formas[1];
}
int travel_plan(int n, int m, int r[][2], int l[], int k, int p[])
{
    G=vector<vii> (n+5);
  for(int i=0;i<m;i++){
    int x=r[i][0];
    int y=r[i][1];
    G[x].pb(mk(y, l[i]));
    G[y].pb(mk(x, l[i]));
  }
  mem(hojas, 0);
  for(int i=0;i<k;i++)hojas[p[i]]=1;
  mem(vis, 0);
  int ans=solve(0,MIN);
  return ans;
}/*
#include "crocodile.h"
#include <stdio.h>
#include <stdlib.h>

#define MAX_N 50000
#define MAX_M 10000000

static int N, M;
static int R[MAX_M][2];
static int L[MAX_M];
static int K;
static int P[MAX_N];
static int solution;

inline
void my_assert(int e) {if (!e) abort();}

void read_input()
{
  int i;
  my_assert(3==scanf("%d %d %d",&N,&M,&K));
  for(i=0; i<M; i++)
    my_assert(3==scanf("%d %d %d",&R[i][0],&R[i][1],&L[i]));
  for(i=0; i<K; i++)
    my_assert(1==scanf("%d",&P[i]));
  my_assert(1==scanf("%d",&solution));
}

int main()
{
  int ans;
  read_input();
  ans = travel_plan(N,M,R,L,K,P);
  if(ans==solution)
    printf("Correct.\n");
  else
    printf("Incorrect. Returned %d, Expected %d.\n",ans,solution);

  return 0;
}

*/

Compilation message

crocodile.cpp: In function 'int solve(int, int)':
crocodile.cpp:27:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<G[x].size ();i++){
                 ~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 512 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 5 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 512 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 5 ms 512 KB Output is correct
9 Runtime error 194 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 512 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 5 ms 512 KB Output is correct
9 Runtime error 194 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Halted 0 ms 0 KB -