Submission #709132

#TimeUsernameProblemLanguageResultExecution timeMemory
709132ono_de206악어의 지하 도시 (IOI11_crocodile)C++14
46 / 100
4 ms2772 KiB
#include "crocodile.h"
#include<bits/stdc++.h>
using namespace std;

#define pb push_back

const int inf = 1e9 + 10;
const int mxn = 1e5 + 10;
int a[mxn], is[mxn], n;
vector<pair<int, int>> g[mxn];
map<int, int> mp;

int solve(int x) {
  if(mp.find(x) != mp.end()) return mp[x];
  if(is[x]) return 0;
  vector<int> tmp;
  int &ret = mp[x];
  ret = inf;
  for(auto [y, t] : g[x]) {
    tmp.pb(solve(y) + t);
  }
  sort(tmp.begin(), tmp.end());
  ret = tmp[1];
  return ret;
}

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
  n = N;
  for(int i = 0; i < M; i++) {
    int x = R[i][0];
    int y = R[i][1];
    g[x].pb({y, L[i]});
    g[y].pb({x, L[i]});
  }
  for(int i = 0; i < K; i++) {
    is[P[i]] = 1;
  }
  if(solve(0) == inf) while(1);
  return solve(0);
}


Compilation message (stderr)

crocodile.cpp: In function 'int solve(int)':
crocodile.cpp:19:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   19 |   for(auto [y, t] : g[x]) {
      |            ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...