Submission #625350

# Submission time Handle Problem Language Result Execution time Memory
625350 2022-08-10T06:11:42 Z EthanKim8683 Crocodile's Underground City (IOI11_crocodile) C++17
46 / 100
6 ms 3796 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;

vector<pair<I,I>>adjs[N];
B exis[N];
I viss[N];
priority_queue<pair<Lli,I>,vector<pair<Lli,I>>,greater<pair<Lli,I>>>que;

I travel_plan(I n,I m,I r[][2],I l[],I k,I p[]){
  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});
  }
  for(I i=0;i<k;i++)
    for(auto[b,d]:adjs[p[i]])
      que.push({d,b});
  while(!que.empty()){
    auto[dis,a]=que.top();
    que.pop();
    if(viss[a]>=2)continue;
    if(++viss[a]==2){
      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
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Correct 1 ms 2644 KB Output is correct
4 Correct 2 ms 2644 KB Output is correct
5 Correct 2 ms 2644 KB Output is correct
6 Correct 1 ms 2644 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 2 ms 2664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Correct 1 ms 2644 KB Output is correct
4 Correct 2 ms 2644 KB Output is correct
5 Correct 2 ms 2644 KB Output is correct
6 Correct 1 ms 2644 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 2 ms 2664 KB Output is correct
9 Correct 3 ms 3156 KB Output is correct
10 Correct 2 ms 2648 KB Output is correct
11 Correct 3 ms 2792 KB Output is correct
12 Correct 6 ms 3796 KB Output is correct
13 Correct 4 ms 3156 KB Output is correct
14 Incorrect 1 ms 2644 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Correct 1 ms 2644 KB Output is correct
4 Correct 2 ms 2644 KB Output is correct
5 Correct 2 ms 2644 KB Output is correct
6 Correct 1 ms 2644 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 2 ms 2664 KB Output is correct
9 Correct 3 ms 3156 KB Output is correct
10 Correct 2 ms 2648 KB Output is correct
11 Correct 3 ms 2792 KB Output is correct
12 Correct 6 ms 3796 KB Output is correct
13 Correct 4 ms 3156 KB Output is correct
14 Incorrect 1 ms 2644 KB Output isn't correct
15 Halted 0 ms 0 KB -