답안 #978958

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
978958 2024-05-10T04:56:18 Z Panda50O 악어의 지하 도시 (IOI11_crocodile) C++14
89 / 100
424 ms 61672 KB
#include "crocodile.h"
#include<bits/stdc++.h>
using namespace std;

#define MAX_N 50005
#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];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6488 KB Output is correct
4 Correct 2 ms 6592 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 2 ms 6488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6488 KB Output is correct
4 Correct 2 ms 6592 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 2 ms 6488 KB Output is correct
9 Correct 3 ms 6744 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 2 ms 6492 KB Output is correct
12 Correct 4 ms 7004 KB Output is correct
13 Correct 4 ms 7192 KB Output is correct
14 Correct 1 ms 6584 KB Output is correct
15 Correct 2 ms 6608 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6488 KB Output is correct
4 Correct 2 ms 6592 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 2 ms 6488 KB Output is correct
9 Correct 3 ms 6744 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 2 ms 6492 KB Output is correct
12 Correct 4 ms 7004 KB Output is correct
13 Correct 4 ms 7192 KB Output is correct
14 Correct 1 ms 6584 KB Output is correct
15 Correct 2 ms 6608 KB Output is correct
16 Correct 424 ms 61672 KB Output is correct
17 Runtime error 50 ms 22876 KB Execution killed with signal 11
18 Halted 0 ms 0 KB -