답안 #220562

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
220562 2020-04-08T04:49:24 Z anonymous 악어의 지하 도시 (IOI11_crocodile) C++14
100 / 100
1715 ms 111708 KB
#include "crocodile.h"
#include <iostream>
#include <vector>
#include <queue>
#include<set>
#include <utility>
#define MAXN 100005
using namespace std;
vector<pair<int,int> > adj[MAXN];
int dp[MAXN]; //min, second min, number of adj
bool done[MAXN];
multiset <int> V[MAXN];
priority_queue <pair<int,int> > PQ;
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
  for (int i=0; i<N; i++) {
    dp[i]  = 1e9 + 10;
  }
  for (int i=0; i<K; i++) {
      dp[P[i]] =  0;
      PQ.push({0,P[i]});
  }
  for (int i=0; i<M; i++) {
        adj[R[i][0]].push_back({R[i][1], L[i]});
        adj[R[i][1]].push_back({R[i][0], L[i]});
  }
  while (PQ.size()) {
    int cur = PQ.top().second;
    dp[cur] = min(dp[cur], -PQ.top().first);
    PQ.pop();
    if (done[cur]) {continue;}
    done[cur] = true;
    for (auto v: adj[cur]) {
        if (!done[v.first]) {
            V[v.first].insert(dp[cur] + v.second);
            if (V[v.first].size() >= 2) {
                auto it = ++V[v.first].begin();
                PQ.push({-(*it), v.first});
            }
        }
    }
  }
  return(dp[0]);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 7424 KB Output is correct
2 Correct 8 ms 7424 KB Output is correct
3 Correct 9 ms 7424 KB Output is correct
4 Correct 9 ms 7552 KB Output is correct
5 Correct 9 ms 7552 KB Output is correct
6 Correct 10 ms 7424 KB Output is correct
7 Correct 10 ms 7552 KB Output is correct
8 Correct 9 ms 7552 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 7424 KB Output is correct
2 Correct 8 ms 7424 KB Output is correct
3 Correct 9 ms 7424 KB Output is correct
4 Correct 9 ms 7552 KB Output is correct
5 Correct 9 ms 7552 KB Output is correct
6 Correct 10 ms 7424 KB Output is correct
7 Correct 10 ms 7552 KB Output is correct
8 Correct 9 ms 7552 KB Output is correct
9 Correct 12 ms 7808 KB Output is correct
10 Correct 9 ms 7424 KB Output is correct
11 Correct 10 ms 7552 KB Output is correct
12 Correct 19 ms 8192 KB Output is correct
13 Correct 14 ms 8320 KB Output is correct
14 Correct 9 ms 7424 KB Output is correct
15 Correct 11 ms 7552 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 7424 KB Output is correct
2 Correct 8 ms 7424 KB Output is correct
3 Correct 9 ms 7424 KB Output is correct
4 Correct 9 ms 7552 KB Output is correct
5 Correct 9 ms 7552 KB Output is correct
6 Correct 10 ms 7424 KB Output is correct
7 Correct 10 ms 7552 KB Output is correct
8 Correct 9 ms 7552 KB Output is correct
9 Correct 12 ms 7808 KB Output is correct
10 Correct 9 ms 7424 KB Output is correct
11 Correct 10 ms 7552 KB Output is correct
12 Correct 19 ms 8192 KB Output is correct
13 Correct 14 ms 8320 KB Output is correct
14 Correct 9 ms 7424 KB Output is correct
15 Correct 11 ms 7552 KB Output is correct
16 Correct 1715 ms 93288 KB Output is correct
17 Correct 111 ms 27512 KB Output is correct
18 Correct 162 ms 28920 KB Output is correct
19 Correct 1623 ms 111708 KB Output is correct
20 Correct 709 ms 104796 KB Output is correct
21 Correct 62 ms 16508 KB Output is correct
22 Correct 660 ms 92792 KB Output is correct