답안 #735881

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

using namespace std;
typedef long long ll;

ll INF=LONG_MAX;
vector<pair<ll,  ll> >graff[100010];
bool izlaz[100010], check[100010];
int T[100010];

void dfs(int v)
{
    if(check[v])return;
    check[v]=true;
    if(izlaz[v]){T[v]=0; return;}
    ll m1=INF, m2=INF;
    for(int i=0; i<graff[v].size(); i++)
    {
        dfs(graff[v][i]);
        if(T[graff[v][i]]<m1){m2=m1; m1=T[graff[v][i]];}
        else if(T[graff[v][i]]>=m1 and T[graff[v][i]]<=m2){m2=T[graff[v][i]];}
    }
    T[v]=m2;
    return;
}

int travel_plan(int n, int m, int r[][2], int l[], int k, int p[])
{
    for(int i=0; i<m; i++)
    {
        graff[r[i][0]].push_back({r[i][1], l[i]});
        graff[r[i][1]].push_back({r[i][0], l[i]});
    }
    for(int i=0; i<k; i++)izlaz[p[i]]=true;
    for(int i=0; i<n; i++)T[i]=INF;
    dfs(0);
    return T[0];
}

Compilation message

crocodile.cpp: In function 'void dfs(int)':
crocodile.cpp:18:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |     for(int i=0; i<graff[v].size(); i++)
      |                  ~^~~~~~~~~~~~~~~~
crocodile.cpp:20:24: error: cannot convert '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'} to 'int'
   20 |         dfs(graff[v][i]);
      |                        ^
      |                        |
      |                        __gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type {aka std::pair<long long int, long long int>}
crocodile.cpp:12:14: note:   initializing argument 1 of 'void dfs(int)'
   12 | void dfs(int v)
      |          ~~~~^
crocodile.cpp:21:13: error: no match for 'operator[]' (operand types are 'int [100010]' and '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'})
   21 |         if(T[graff[v][i]]<m1){m2=m1; m1=T[graff[v][i]];}
      |             ^
crocodile.cpp:21:42: error: no match for 'operator[]' (operand types are 'int [100010]' and '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'})
   21 |         if(T[graff[v][i]]<m1){m2=m1; m1=T[graff[v][i]];}
      |                                          ^
crocodile.cpp:22:18: error: no match for 'operator[]' (operand types are 'int [100010]' and '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'})
   22 |         else if(T[graff[v][i]]>=m1 and T[graff[v][i]]<=m2){m2=T[graff[v][i]];}
      |                  ^
crocodile.cpp:22:41: error: no match for 'operator[]' (operand types are 'int [100010]' and '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'})
   22 |         else if(T[graff[v][i]]>=m1 and T[graff[v][i]]<=m2){m2=T[graff[v][i]];}
      |                                         ^
crocodile.cpp:22:64: error: no match for 'operator[]' (operand types are 'int [100010]' and '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'})
   22 |         else if(T[graff[v][i]]>=m1 and T[graff[v][i]]<=m2){m2=T[graff[v][i]];}
      |                                                                ^