답안 #308817

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
308817 2020-10-02T04:10:39 Z juggernaut 악어의 지하 도시 (IOI11_crocodile) C++14
컴파일 오류
0 ms 0 KB
#include"crocodile.h"
#include<bits/stdc++.h>
#define fr first
#define sc second
using namespace std;
vector<pair<int,int>>g[100005];
pair<int,int>a[100005];
int inf=2e9;
int travel_plan(int n,int m,int r[][2],int l[],int k,int p[]){
    for(i=0;i<n;i++)a[i]={inf,inf};
    priority_queue<pair<int,int>>q;
    for(int i=0;i<m;i++){
        g[r[i][0]].push_back({r[i][1],l[i]});
        g[r[i][1]].push_back({r[i][0],l[i]});
    }
    for(int i=0;i<k;i++)
        q.push({0,p[i]}),a[p[i]]={0,0};
    while(!q.size()){
        int len=-q.top().fr;
        int v=q.top().sc;
        q.pop();
        if(len>a[v].second)continue;
        for(auto to:g[v])
            if(a[to.fr].second>len+to.sc){
                a[to.fr].second=len+to.sc;
                if(a[to].first>a[to].second)swap(a[to].first,a[to].second);
                if(a[to].second<inf)q.push({-a[to].second,to});
            }
    }
    return a[0].sc;
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:10:9: error: 'i' was not declared in this scope
   10 |     for(i=0;i<n;i++)a[i]={inf,inf};
      |         ^
crocodile.cpp:26:21: error: no match for 'operator[]' (operand types are 'std::pair<int, int> [100005]' and 'std::pair<int, int>')
   26 |                 if(a[to].first>a[to].second)swap(a[to].first,a[to].second);
      |                     ^
crocodile.cpp:26:33: error: no match for 'operator[]' (operand types are 'std::pair<int, int> [100005]' and 'std::pair<int, int>')
   26 |                 if(a[to].first>a[to].second)swap(a[to].first,a[to].second);
      |                                 ^
crocodile.cpp:26:51: error: no match for 'operator[]' (operand types are 'std::pair<int, int> [100005]' and 'std::pair<int, int>')
   26 |                 if(a[to].first>a[to].second)swap(a[to].first,a[to].second);
      |                                                   ^
crocodile.cpp:26:63: error: no match for 'operator[]' (operand types are 'std::pair<int, int> [100005]' and 'std::pair<int, int>')
   26 |                 if(a[to].first>a[to].second)swap(a[to].first,a[to].second);
      |                                                               ^
crocodile.cpp:27:21: error: no match for 'operator[]' (operand types are 'std::pair<int, int> [100005]' and 'std::pair<int, int>')
   27 |                 if(a[to].second<inf)q.push({-a[to].second,to});
      |                     ^
crocodile.cpp:27:47: error: no match for 'operator[]' (operand types are 'std::pair<int, int> [100005]' and 'std::pair<int, int>')
   27 |                 if(a[to].second<inf)q.push({-a[to].second,to});
      |                                               ^
crocodile.cpp:27:62: error: no matching function for call to 'std::priority_queue<std::pair<int, int> >::push(<brace-enclosed initializer list>)'
   27 |                 if(a[to].second<inf)q.push({-a[to].second,to});
      |                                                              ^
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<int, int>; _Sequence = std::vector<std::pair<int, int> >; _Compare = std::less<std::pair<int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::pair<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<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<int, int>; _Sequence = std::vector<std::pair<int, int> >; _Compare = std::less<std::pair<int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::pair<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<int, int> >::value_type&&' {aka 'std::pair<int, int>&&'}
  635 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~