Submission #540528

# Submission time Handle Problem Language Result Execution time Memory
540528 2022-03-20T17:33:44 Z Gurban Crocodile's Underground City (IOI11_crocodile) C++17
100 / 100
549 ms 63244 KB
#include "crocodile.h"
#include "bits/stdc++.h"
using namespace std;

using ll = long long;

const int maxn=1e5+5;
bool vis[maxn];
int dis[maxn][2];
vector<pair<int,int>>E[maxn];

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
  for(int i = 0;i < M;i++){
    E[R[i][0]].push_back({R[i][1],L[i]});
    E[R[i][1]].push_back({R[i][0],L[i]});
  }
  for(int i = 0;i < N;i++) dis[i][0] = dis[i][1] = 1e9;
  priority_queue<pair<int,int>>q;
  for(int i = 0;i < K;i++){
    dis[P[i]][0] = dis[P[i]][1] = 0;
    q.push({0,P[i]});
  }
  while(!q.empty()){
    int x = q.top().second;
    q.pop();
    if(vis[x]) continue;
    vis[x] = 1;
    for(auto i : E[x]){
      if(dis[x][1] + i.second >= dis[i.first][1]) continue;
      if(dis[x][1] + i.second < dis[i.first][0]){
        dis[i.first][1] = dis[i.first][0];
        dis[i.first][0] = dis[x][1] + i.second;
        q.push({-dis[i.first][1],i.first});
      }
      else if(dis[x][1] + i.second < dis[i.first][1]){
        dis[i.first][1] = dis[x][1] + i.second;
        q.push({-dis[i.first][1],i.first});
      }
    }
  }
  // for(int i = 0;i < N;i++){
  //   cout<<i<<' '<<dis[i][0]<<' '<<dis[i][1]<<'\n';
  // }
  return dis[0][1];
}


# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2660 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 3 ms 2644 KB Output is correct
5 Correct 2 ms 2772 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 2 ms 2760 KB Output is correct
8 Correct 3 ms 2644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2660 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 3 ms 2644 KB Output is correct
5 Correct 2 ms 2772 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 2 ms 2760 KB Output is correct
8 Correct 3 ms 2644 KB Output is correct
9 Correct 4 ms 2932 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 3 ms 2708 KB Output is correct
12 Correct 7 ms 3156 KB Output is correct
13 Correct 7 ms 3092 KB Output is correct
14 Correct 2 ms 2644 KB Output is correct
15 Correct 3 ms 2772 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2660 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 3 ms 2644 KB Output is correct
5 Correct 2 ms 2772 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 2 ms 2760 KB Output is correct
8 Correct 3 ms 2644 KB Output is correct
9 Correct 4 ms 2932 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 3 ms 2708 KB Output is correct
12 Correct 7 ms 3156 KB Output is correct
13 Correct 7 ms 3092 KB Output is correct
14 Correct 2 ms 2644 KB Output is correct
15 Correct 3 ms 2772 KB Output is correct
16 Correct 439 ms 58224 KB Output is correct
17 Correct 86 ms 14956 KB Output is correct
18 Correct 113 ms 16372 KB Output is correct
19 Correct 549 ms 63244 KB Output is correct
20 Correct 280 ms 49512 KB Output is correct
21 Correct 42 ms 8068 KB Output is correct
22 Correct 319 ms 46340 KB Output is correct