답안 #445304

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
445304 2021-07-17T11:30:28 Z prvocislo 악어의 지하 도시 (IOI11_crocodile) C++17
100 / 100
1434 ms 62640 KB
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;

const int inf = 1e9 + 5;
int travel_plan(int n, int m, int e[][2], int l[], int k, int p[])
{
  vector<vector<pair<int, int> > > g(n);
  for (int i = 0; i < m; i++) g[e[i][0]].push_back({e[i][1], l[i]}), g[e[i][1]].push_back({e[i][0], l[i]});
  vector<vector<int> > best2(n);
  vector<int> d(n, inf);
  set<pair<int, int> > s;
  for (int i = 0; i < k; i++) s.insert({0, p[i]});
  while (!s.empty())
  {
    int dist = s.begin()->first, u = s.begin()->second;
    s.erase(s.begin());
    if (d[u] != inf) continue;
    d[u] = dist;
    for (const pair<int, int> &v : g[u])
    {
      if (d[v.first] != inf) continue;
      best2[v.first].push_back({d[u] + v.second});
      sort(best2[v.first].begin(), best2[v.first].end());
      if (best2[v.first].size() > 2) best2[v.first].pop_back();
      if (best2[v.first].size() == 2) s.insert({best2[v.first][1], v.first});
    }
  }
  return d[0];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 436 KB Output is correct
5 Correct 2 ms 460 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 436 KB Output is correct
5 Correct 2 ms 460 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 3 ms 588 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 5 ms 716 KB Output is correct
13 Correct 4 ms 844 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 436 KB Output is correct
5 Correct 2 ms 460 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 3 ms 588 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 5 ms 716 KB Output is correct
13 Correct 4 ms 844 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1068 ms 52792 KB Output is correct
17 Correct 102 ms 18756 KB Output is correct
18 Correct 152 ms 19912 KB Output is correct
19 Correct 1434 ms 62640 KB Output is correct
20 Correct 397 ms 43328 KB Output is correct
21 Correct 49 ms 7492 KB Output is correct
22 Correct 458 ms 40760 KB Output is correct