Submission #978959

# Submission time Handle Problem Language Result Execution time Memory
978959 2024-05-10T04:57:01 Z Panda50O Crocodile's Underground City (IOI11_crocodile) C++14
100 / 100
493 ms 71892 KB
#include "crocodile.h"
#include<bits/stdc++.h>
using namespace std;

#define MAX_N 100005
#define MAX_M 1000005
#define pii pair<int,int>

vector<pair<int,int>> adj[MAX_N];
int vis[MAX_N] = {0};
priority_queue<pii, vector<pii>, greater<pii>> pq;
int dist[MAX_N] = {0};

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
  for(int i = 0; i < K; ++i) {
    vis[P[i]] = 2;
  }
  for(int i = 0; i < M; ++i) {
    int a = R[i][0], b = R[i][1];
    if(!(vis[a] == 2 && vis[b] == 2)) {
      if(!(vis[a] == 2)) swap(a, b);
      if(vis[a] == 2) pq.emplace(L[i], b);
    }
    adj[R[i][0]].emplace_back(R[i][1], L[i]);
    adj[R[i][1]].emplace_back(R[i][0], L[i]);
  }

  while(!pq.empty()) {
    int d = pq.top().first, u = pq.top().second;
    pq.pop();
    
    if(vis[u] == 2) continue;
    else if(vis[u] == 1) {
      vis[u] = 2;
      dist[u] = d;
      for(auto _ : adj[u]) {
        int v = _.first, w = _.second;
        if(vis[v] == 2) continue;
        pq.emplace(d + w, v);
      }
    }
    else {
      vis[u] = 1;
    }
  }
  return dist[0];
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6576 KB Output is correct
4 Correct 2 ms 6492 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 2 ms 6492 KB Output is correct
7 Correct 2 ms 6492 KB Output is correct
8 Correct 2 ms 6492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6576 KB Output is correct
4 Correct 2 ms 6492 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 2 ms 6492 KB Output is correct
7 Correct 2 ms 6492 KB Output is correct
8 Correct 2 ms 6492 KB Output is correct
9 Correct 3 ms 6748 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 2 ms 6492 KB Output is correct
12 Correct 5 ms 7004 KB Output is correct
13 Correct 4 ms 7000 KB Output is correct
14 Correct 1 ms 6488 KB Output is correct
15 Correct 2 ms 6492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6576 KB Output is correct
4 Correct 2 ms 6492 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 2 ms 6492 KB Output is correct
7 Correct 2 ms 6492 KB Output is correct
8 Correct 2 ms 6492 KB Output is correct
9 Correct 3 ms 6748 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 2 ms 6492 KB Output is correct
12 Correct 5 ms 7004 KB Output is correct
13 Correct 4 ms 7000 KB Output is correct
14 Correct 1 ms 6488 KB Output is correct
15 Correct 2 ms 6492 KB Output is correct
16 Correct 425 ms 54308 KB Output is correct
17 Correct 52 ms 13396 KB Output is correct
18 Correct 69 ms 18000 KB Output is correct
19 Correct 493 ms 71892 KB Output is correct
20 Correct 337 ms 62908 KB Output is correct
21 Correct 29 ms 10296 KB Output is correct
22 Correct 310 ms 51796 KB Output is correct