답안 #1005297

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1005297 2024-06-22T09:57:54 Z Gray 악어의 지하 도시 (IOI11_crocodile) C++17
100 / 100
491 ms 96324 KB
#include "crocodile.h"
#include <queue>
#include <utility>
#include <vector>
#define ll long long
#define ff first
#define ss second
#define ln "\n"
using namespace std;

const ll INF = 2e18;

vector<pair<ll, pair<ll, ll>>> e;
vector<vector<ll>> A;
ll n, m, k;
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
  n=N; m=M; k=K;
  e.resize(m);
  A.resize(n);
  for (ll i=0; i<m; i++){
    e[i] = {L[i], {R[i][0], R[i][1]}};
    A[R[i][0]].push_back(i);
    A[R[i][1]].push_back(i);
  }
  vector<ll> dist(n, INF);
  vector<ll> vis(n, 0);
  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll,ll>>> que;
  for (ll i=0; i<K; i++){
    vis[P[i]]=1;
    que.push({0, P[i]});
  }
  while (!que.empty()){
    auto cur = que.top();
    que.pop();
    if (vis[cur.ss]==2) continue;
    vis[cur.ss]++;
    if (vis[cur.ss]==1) {continue;}
    else dist[cur.ss]=cur.ff;
    for(auto i:A[cur.ss]){
      ll v = e[i].ss.ff^e[i].ss.ss^cur.ss;
      if (vis[v]<2){
        que.push({e[i].ff+cur.ff, v});
      }
    }
  }
  return dist[0];
}


# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2480 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2480 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 3 ms 2908 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 1 ms 2652 KB Output is correct
12 Correct 3 ms 3420 KB Output is correct
13 Correct 3 ms 3512 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 2 ms 2516 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2480 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 3 ms 2908 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 1 ms 2652 KB Output is correct
12 Correct 3 ms 3420 KB Output is correct
13 Correct 3 ms 3512 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 2 ms 2516 KB Output is correct
16 Correct 457 ms 92044 KB Output is correct
17 Correct 47 ms 20308 KB Output is correct
18 Correct 77 ms 22148 KB Output is correct
19 Correct 491 ms 96324 KB Output is correct
20 Correct 339 ms 85184 KB Output is correct
21 Correct 26 ms 11356 KB Output is correct
22 Correct 283 ms 64400 KB Output is correct