답안 #363636

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
363636 2021-02-06T17:49:44 Z David_M 악어의 지하 도시 (IOI11_crocodile) C++14
컴파일 오류
0 ms 0 KB
#include "crocodile.h"
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;

vector<pair<int, int> > v[N];
priority_queue <pair<long long, int>, vector<pair<long long, int> >, greater<pair<long long, int> > > q;

int travel_plan(int n, int m, int R[][2], int L[], int k, int P[]){
	
	for (int i=0; i<m; i++)
		v[R[i][0]].push_back({v[R[i][1]], L[i]}),
		v[R[i][1]].push_back({v[R[i][0]], L[i]});
	
	for (int i=0; i<n; i++)D[i]={INF, INF};
	for (int i=0; i<k; i++)D[p[i]]={0, 0},q.push({0, p[i]});
	
	while(!q.empty()){
		long long d=q.top().F;
		int x=q.top().S;
		q.pop();
		if(d!=D[x].F)continue;
		
		for (auto [y, l] : v[x]){
			if(D[y].F>d+l){
				D[y].F=d+l;
				if(D[y].F<D[y].S)swap(D[y].F, D[y].S);
				if(D[y].F!=INF)q.push({D[y].F, y});
			}
		}
	}
	return D[0].F;
}

Compilation message

crocodile.cpp:7:27: error: 'N' was not declared in this scope
    7 | vector<pair<int, int> > v[N];
      |                           ^
crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:13:3: error: 'v' was not declared in this scope
   13 |   v[R[i][0]].push_back({v[R[i][1]], L[i]}),
      |   ^
crocodile.cpp:16:25: error: 'D' was not declared in this scope
   16 |  for (int i=0; i<n; i++)D[i]={INF, INF};
      |                         ^
crocodile.cpp:16:31: error: 'INF' was not declared in this scope
   16 |  for (int i=0; i<n; i++)D[i]={INF, INF};
      |                               ^~~
crocodile.cpp:17:25: error: 'D' was not declared in this scope
   17 |  for (int i=0; i<k; i++)D[p[i]]={0, 0},q.push({0, p[i]});
      |                         ^
crocodile.cpp:17:27: error: 'p' was not declared in this scope
   17 |  for (int i=0; i<k; i++)D[p[i]]={0, 0},q.push({0, p[i]});
      |                           ^
crocodile.cpp:17:56: error: no matching function for call to 'std::priority_queue<std::pair<long long int, int>, std::vector<std::pair<long long int, int> >, std::greater<std::pair<long long int, int> > >::push(<brace-enclosed initializer list>)'
   17 |  for (int i=0; i<k; i++)D[p[i]]={0, 0},q.push({0, p[i]});
      |                                                        ^
In file included from /usr/include/c++/9/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:86,
                 from crocodile.cpp:2:
/usr/include/c++/9/bits/stl_queue.h:627:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::pair<long long int, int>; _Sequence = std::vector<std::pair<long long int, int> >; _Compare = std::greater<std::pair<long long int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::pair<long long int, int>]'
  627 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/9/bits/stl_queue.h:627:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<long long int, int>&'}
  627 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/9/bits/stl_queue.h:635:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(std::priority_queue<_Tp, _Sequence, _Compare>::value_type&&) [with _Tp = std::pair<long long int, int>; _Sequence = std::vector<std::pair<long long int, int> >; _Compare = std::greater<std::pair<long long int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::pair<long long int, int>]'
  635 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/9/bits/stl_queue.h:635:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<std::pair<long long int, int>, std::vector<std::pair<long long int, int> >, std::greater<std::pair<long long int, int> > >::value_type&&' {aka 'std::pair<long long int, int>&&'}
  635 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
crocodile.cpp:23:9: error: 'D' was not declared in this scope
   23 |   if(d!=D[x].F)continue;
      |         ^
crocodile.cpp:25:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   25 |   for (auto [y, l] : v[x]){
      |             ^
crocodile.cpp:25:22: error: 'v' was not declared in this scope
   25 |   for (auto [y, l] : v[x]){
      |                      ^
crocodile.cpp:26:7: error: 'D' was not declared in this scope
   26 |    if(D[y].F>d+l){
      |       ^
crocodile.cpp:29:16: error: 'INF' was not declared in this scope
   29 |     if(D[y].F!=INF)q.push({D[y].F, y});
      |                ^~~
crocodile.cpp:29:38: error: no matching function for call to 'std::priority_queue<std::pair<long long int, int>, std::vector<std::pair<long long int, int> >, std::greater<std::pair<long long int, int> > >::push(<brace-enclosed initializer list>)'
   29 |     if(D[y].F!=INF)q.push({D[y].F, y});
      |                                      ^
In file included from /usr/include/c++/9/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:86,
                 from crocodile.cpp:2:
/usr/include/c++/9/bits/stl_queue.h:627:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::pair<long long int, int>; _Sequence = std::vector<std::pair<long long int, int> >; _Compare = std::greater<std::pair<long long int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::pair<long long int, int>]'
  627 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/9/bits/stl_queue.h:627:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<long long int, int>&'}
  627 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/9/bits/stl_queue.h:635:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(std::priority_queue<_Tp, _Sequence, _Compare>::value_type&&) [with _Tp = std::pair<long long int, int>; _Sequence = std::vector<std::pair<long long int, int> >; _Compare = std::greater<std::pair<long long int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::pair<long long int, int>]'
  635 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/9/bits/stl_queue.h:635:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<std::pair<long long int, int>, std::vector<std::pair<long long int, int> >, std::greater<std::pair<long long int, int> > >::value_type&&' {aka 'std::pair<long long int, int>&&'}
  635 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
crocodile.cpp:33:9: error: 'D' was not declared in this scope
   33 |  return D[0].F;
      |         ^