답안 #884161

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
884161 2023-12-06T16:28:45 Z Glauco 악어의 지하 도시 (IOI11_crocodile) C++17
100 / 100
345 ms 45772 KB
#include <bits/stdc++.h>
using namespace std;
ifstream fin("input.txt");
ofstream fout("output.txt");
 
vector<vector<pair<int, int>>> g;
 
extern int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
  g.resize(N);
  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]});
  }
  
  vector<int> vis(N, 0);
  vector<pair<int, int>> dist(N, {1e9, 1e9});
  priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
 
  for(int i = 0; i < K; i++){
    vis[P[i]] = 1;
    pq.push({0, P[i]});
  }
 
  while(!pq.empty()){
    int d = pq.top().first, node = pq.top().second;
    pq.pop();
 
    if(vis[node] == 0){
      vis[node] = 1;
      continue;
    }else if(vis[node] == 2) continue;
 
    if(node == 0) return d;
    vis[node]++;
 
    for(auto i : g[node]){
      if(dist[i.first].second < d+i.second) continue;
      else if(dist[i.first].first > d+i.second){
        dist[i.first].second = dist[i.first].first;
        dist[i.first].first = d+i.second;
      }else{
        dist[i.first].second = d+i.second;
      }
 
      pq.push({d+i.second, i.first});
    }
  }
  
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 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 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 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 4700 KB Output is correct
10 Correct 1 ms 4444 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 4700 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 2 ms 4440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 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 4700 KB Output is correct
10 Correct 1 ms 4444 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 4700 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 2 ms 4440 KB Output is correct
16 Correct 291 ms 41528 KB Output is correct
17 Correct 56 ms 12728 KB Output is correct
18 Correct 60 ms 13908 KB Output is correct
19 Correct 345 ms 45772 KB Output is correct
20 Correct 216 ms 34644 KB Output is correct
21 Correct 28 ms 7768 KB Output is correct
22 Correct 234 ms 32084 KB Output is correct