제출 #639876

#제출 시각아이디문제언어결과실행 시간메모리
639876Stavab악어의 지하 도시 (IOI11_crocodile)C++14
컴파일 에러
0 ms0 KiB
#include "crocodile.h" #include <iostream> #include <vector> #include <utility> #include <set> using namespace std; #define INF 9999999999 vector<vector<pair<int, int>>> tree; vector<long long> times; vector<int> visited; void dfs(int n) { if(visited[n]) return; else visited[n] = 1; set<long long> s; for(int i = 0; i < tree[n].size(); i++) { dfs(tree[n][i].first); s.insert(times[tree[n][i].first] + tree[n][i].second); } if(*(++s.begin()) >= INF) times[n] = INF; else times[n] = *(++s.begin()); } int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) { tree.assign(N, vector<pair<int, int>>()) for(int i = 0; i < N - 1; i++) { tree[R[i][0]].push_back(make_pair(R[i][1], L[i])); tree[R[i][1]].push_back(make_pair(R[i][0], L[i])); } for(int i = 0; i < N; i++) times[i] = INF; for(int i = 0; i < K; i++) times[P[i]] = 0; dfs(0); return (int)times[0]; }

컴파일 시 표준 에러 (stderr) 메시지

crocodile.cpp: In function 'void dfs(int)':
crocodile.cpp:23:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     for(int i = 0; i < tree[n].size(); i++)
      |                    ~~^~~~~~~~~~~~~~~~
crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:37:45: error: expected ';' before 'for'
   37 |     tree.assign(N, vector<pair<int, int>>())
      |                                             ^
      |                                             ;
   38 | 
   39 |     for(int i = 0; i < N - 1; i++)
      |     ~~~                                      
crocodile.cpp:39:20: error: 'i' was not declared in this scope
   39 |     for(int i = 0; i < N - 1; i++)
      |                    ^