답안 #931163

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
931163 2024-02-21T10:26:09 Z PieArmy 악어의 지하 도시 (IOI11_crocodile) C++17
100 / 100
494 ms 113464 KB
#include "crocodile.h"
#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define sp << " " <<
using namespace std;

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
  vector<ll>komsu[N],cos[N];
  for(int i=0;i<M;i++){
    komsu[R[i][0]].pb(R[i][1]);
    komsu[R[i][1]].pb(R[i][0]);
    cos[R[i][0]].pb(L[i]);
    cos[R[i][1]].pb(L[i]);
  }
  //using wtf = pair<ll,int>;
  priority_queue<pair<ll,int>/*,vector<wtf>,greater<wtf>*/>pq;
  int say[N];for(int i=0;i<N;i++)say[i]=0;
  for(int i=0;i<K;i++){
    say[P[i]]=1;
    pq.push({0,P[i]});
  }
  while(pq.size()){
    ll sum=-pq.top().first;
    int pos=pq.top().second;
    //cout << sum sp pos << '\n';
    pq.pop();
    if(say[pos]==2)continue;
    say[pos]++;
    if(say[pos]==1)continue;
    if(!pos){
      return sum;
    }
    for(int i=0;i<ll(komsu[pos].size());i++){
      pq.push({-sum-cos[pos][i],komsu[pos][i]});
    }
  }
  return -1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4536 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 2 ms 4700 KB Output is correct
5 Correct 1 ms 4700 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4700 KB Output is correct
8 Correct 1 ms 4700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4536 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 2 ms 4700 KB Output is correct
5 Correct 1 ms 4700 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4700 KB Output is correct
8 Correct 1 ms 4700 KB Output is correct
9 Correct 2 ms 4956 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 2 ms 4700 KB Output is correct
12 Correct 5 ms 5600 KB Output is correct
13 Correct 3 ms 5704 KB Output is correct
14 Correct 1 ms 4540 KB Output is correct
15 Correct 2 ms 4700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4536 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 2 ms 4700 KB Output is correct
5 Correct 1 ms 4700 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4700 KB Output is correct
8 Correct 1 ms 4700 KB Output is correct
9 Correct 2 ms 4956 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 2 ms 4700 KB Output is correct
12 Correct 5 ms 5600 KB Output is correct
13 Correct 3 ms 5704 KB Output is correct
14 Correct 1 ms 4540 KB Output is correct
15 Correct 2 ms 4700 KB Output is correct
16 Correct 421 ms 113464 KB Output is correct
17 Correct 78 ms 22260 KB Output is correct
18 Correct 83 ms 23728 KB Output is correct
19 Correct 494 ms 106020 KB Output is correct
20 Correct 251 ms 104792 KB Output is correct
21 Correct 38 ms 11856 KB Output is correct
22 Correct 458 ms 66084 KB Output is correct