답안 #258444

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
258444 2020-08-05T23:32:12 Z monus1042 악어의 지하 도시 (IOI11_crocodile) C++17
컴파일 오류
0 ms 0 KB
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<ll> vll;
#define pb push_back
#define mkp make_pair
#define all(X) X.begin(), X.end()

const int MAXS = 100002;
const ll inf = 1e15;
vector< pair<int, ll> > g[MAXS];
priority_queue < pair<ll, int>, vector< pair<ll, int> >, greater< pair<ll,int> > > pq;
vll d(MAXS, inf), d2(MAXS, inf);
bool state[MAXS]; // 0 unvisited, 1 minimal obtained

void dj(){
  while(!pq.empty()){
    int auxu = pq.top().second;
    ll w = pq.top().first;
    pq.pop();
    state[auxu] = 1;
    for (int i=0; i<(int)g[auxu].size(); i++){
      int v = g[auxu].first;
      ll wuv = g[auxu].second + w;
      if (wuv < d[v] && !state[v]){
	d[v] = wuv;
	pq.push(mkp(wuv, v));
      }
      else if (wuv >= d[v]){
	d2[v] = min(d2[v], wuv);
      }
    }
  }
}

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
  for (int i=0; i<M; i++){
    g[ R[i][0] ].pb(mkp( R[i][1] , L[i]));
    g[ R[i][1] ].pb(mkp( R[i][0] , L[i]));
  }

  for (int i=0; i<K; i++){
    pq.push(mkp(0, P[i]));
    d[P[i]]=0;
    state[P[i]]=1;
  }

  dj();
  return (int)d2[0];
}

Compilation message

crocodile.cpp: In function 'void dj()':
crocodile.cpp:27:23: error: 'class std::vector<std::pair<int, long long int> >' has no member named 'first'
       int v = g[auxu].first;
                       ^~~~~
crocodile.cpp:28:24: error: 'class std::vector<std::pair<int, long long int> >' has no member named 'second'; did you mean 'cend'?
       ll wuv = g[auxu].second + w;
                        ^~~~~~
                        cend