답안 #122236

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
122236 2019-06-27T22:48:05 Z joseacaz 악어의 지하 도시 (IOI11_crocodile) C++17
컴파일 오류
0 ms 0 KB
//#include "crocodile.h"
#include <bits/stdc++.h>

#define MAX_N 50000
#define MAX_M 10000000
#define MAXN 100005
#define MAXM 1000005

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();}

///SUBMITEAR DESDE AQUI:
/*
#include "crocodile.h"
#include <bits/stdc++.h>
#define MAXN 100005
#define MAXM 1000005*/

using namespace std;
typedef long long ll;

int N, M, K, R[MAXM][2], L[MAXM], P[MAXN];
vector < pair < int, ll > > Graph[MAXN];

ll dfs ( int node, int p = -1 )
{
    if ( Graph[node].size() == 1 )
        return 0;

    vector < ll > A;
    A.clear();
    for ( auto i : Graph[node] )
        if ( i.first != p )
            A.push_back ( dfs ( i.first, node ) + i.second );
    sort ( A.begin(), A.end() );
    return A[1];
}

int travel_plan ( int n, int m, int r[][2], int l[], int k, int p[] )
{
    N = n;
    M = m;
    for ( int i = 0; i < M; i++ )
        R[i][0] = r[i][0], R[i][1] = r[i][1], L[i] = l[i];
    K = k;
    for ( int i = 0; i < K; i++ )
        P[i] = p[i];

    for ( int i = 0; i < M; i++ )
    {
        Graph[R[i][0]].push_back ( {R[i][1], L[i]} );
        Graph[R[i][1]].push_back ( {R[i][0], L[i]} );
    }

    return dfs ( 0 );
}

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

/tmp/ccsBN8Xi.o: In function `read_input()':
grader.cpp:(.text+0x0): multiple definition of `read_input()'
/tmp/ccRr2aBz.o:crocodile.cpp:(.text+0x30): first defined here
/tmp/ccsBN8Xi.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccRr2aBz.o:crocodile.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status