답안 #236284

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
236284 2020-06-01T01:14:19 Z Masterdan 악어의 지하 도시 (IOI11_crocodile) C++14
0 / 100
5 ms 384 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 vis[]){
    vis[x]=1;
    if(hojas[x]==1){
        return 0;
    }
    pq formas;
    for(int i=0;i<G[x].size ();i++){
        ii v=G[x][i];
        int child=v.F, peso=v.S;
        int aux;
        if(vis[child]==0)aux=peso+solve(child, vis);
        formas.push(aux);
    }
    formas.pop();
    return formas.top();
}
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, vis);
  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 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -