답안 #625351

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
625351 2022-08-10T06:16:28 Z EthanKim8683 악어의 지하 도시 (IOI11_crocodile) C++17
46 / 100
4 ms 1108 KB
#include<vector>
#include<algorithm>
#include<queue>
#include<cstdio>

using namespace std;

using I=int;
using B=bool;
using Lli=long long int;

// dijkstra's from all exits
// only push nodes once reachable from two exits

const I N=100000;
const I M=1000000;
const I K=999999;
const Lli MAX=1e18;

I travel_plan(I n,I m,I r[][2],I l[],I k,I p[]){
  vector<vector<pair<I,I>>>adjs(n);
  for(I i=0;i<m;i++){
    I a=r[i][0],b=r[i][1],d=l[i];
    adjs[a].push_back({b,d});
    adjs[b].push_back({a,d});
  }
  priority_queue<pair<I,I>>que;
  for(I i=0;i<k;i++)
    for(auto[b,d]:adjs[p[i]])
      que.push({-d,b});
  vector<I>viss(n,0);
  while(!que.empty()){
    auto[dis,a]=que.top();
    que.pop();
    if(viss[a]>=2)continue;
    if(++viss[a]!=2)continue;
    if(a==0)return -dis;
    for(auto[b,d]:adjs[a])
      que.push({dis-d,b});
  }
  return -1;
}

#ifdef ETHANKIM8683
#include<iostream>
#include<cstdio>

I main(){
  cin.tie(0)->sync_with_stdio(0);
  I n,m;
  cin>>n>>m;
  static I r[M][2];
  for(I i=0;i<m;i++)cin>>r[i][0]>>r[i][1];
  static I l[M];
  for(I i=0;i<m;i++)cin>>l[i];
  I k;
  cin>>k;
  static I p[K];
  for(I i=0;i<k;i++)cin>>p[i];
  printf("%i\n",travel_plan(n,m,r,l,k,p));
  return 0;
}
#endif
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 596 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 4 ms 1108 KB Output is correct
13 Correct 3 ms 1108 KB Output is correct
14 Incorrect 1 ms 340 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 596 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 4 ms 1108 KB Output is correct
13 Correct 3 ms 1108 KB Output is correct
14 Incorrect 1 ms 340 KB Output isn't correct
15 Halted 0 ms 0 KB -