답안 #851176

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
851176 2023-09-18T18:45:32 Z aymanrs 악어의 지하 도시 (IOI11_crocodile) C++17
100 / 100
510 ms 62492 KB
#include <bits/stdc++.h>
#include "crocodile.h"
using namespace std;

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
  vector<pair<int, int>> g[N];
  for(int i = 0;i < M;i++){
    g[R[i][0]].emplace_back(R[i][1], L[i]);
    g[R[i][1]].emplace_back(R[i][0], L[i]);
  }
  long long dp[N], gar[N];
  for(int i = 0;i < N;i++) dp[i] = gar[i] = LONG_LONG_MAX;
  set<pair<long long, int>> s;
  for(int i = 0;i < K;i++) {
    dp[P[i]] = 0;
    s.insert({0, P[i]});
  }
  while(!s.empty()){
    int i = s.begin()->second;
    s.erase(s.begin());
    for(auto [to, c] : g[i]){
      if(dp[to] <= dp[i]+c) continue;
      if(gar[to] == LONG_LONG_MAX){
        gar[to] = dp[i]+c;
        continue;
      }
      if(gar[to] > dp[i]+c){
        if(dp[to] > gar[to]){
          s.erase({dp[to], to});
          dp[to] = gar[to];
          s.insert({dp[to], to});
        }
        gar[to] = dp[i]+c;
        continue;
      }
      s.erase({dp[to], to});
      dp[to] = dp[i]+c;
      s.insert({dp[to], to});
    }
  }
  return dp[0];
}


# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4440 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4440 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4440 KB Output is correct
8 Correct 1 ms 4440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4440 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4440 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4440 KB Output is correct
8 Correct 1 ms 4440 KB Output is correct
9 Correct 2 ms 4440 KB Output is correct
10 Correct 1 ms 4440 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 3 ms 4700 KB Output is correct
13 Correct 3 ms 4696 KB Output is correct
14 Correct 1 ms 4440 KB Output is correct
15 Correct 1 ms 4440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4440 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4440 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4440 KB Output is correct
8 Correct 1 ms 4440 KB Output is correct
9 Correct 2 ms 4440 KB Output is correct
10 Correct 1 ms 4440 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 3 ms 4700 KB Output is correct
13 Correct 3 ms 4696 KB Output is correct
14 Correct 1 ms 4440 KB Output is correct
15 Correct 1 ms 4440 KB Output is correct
16 Correct 370 ms 39352 KB Output is correct
17 Correct 55 ms 16208 KB Output is correct
18 Correct 72 ms 17696 KB Output is correct
19 Correct 510 ms 62492 KB Output is correct
20 Correct 207 ms 47952 KB Output is correct
21 Correct 30 ms 9416 KB Output is correct
22 Correct 241 ms 46404 KB Output is correct