Submission #920859

# Submission time Handle Problem Language Result Execution time Memory
920859 2024-02-03T06:36:29 Z Arp Crocodile's Underground City (IOI11_crocodile) C++17
46 / 100
3 ms 6748 KB
#include<bits/stdc++.h>
#include "crocodile.h"

using namespace std;

using i64 = long long;
const i64 inf = 1e18;
const int N = 1e5;
vector<pair<int,int>> adj[N];
bool good[N],vis[N];
i64 dp[N];

void dfs(int u){
  vis[u] = true;
  for(auto [v,w] : adj[u]){
    if(vis[v]) continue;
    dfs(v);
  }
  i64 m1 = inf;
  i64 m2 = inf;
  for(auto [v,w] : adj[u]){
    if(!good[v]) continue;
    i64 T = dp[v] + w;
    if(m1 > T){
      m2 = m1;
      m1 = T;
    }else if(m2 > T){
      m2 = T;
    }
  }
  if(m2 != inf){
    good[u] = true;
    dp[u] = m2;
  }
}

int travel_plan(int N,int M,int R[][2],int L[],int K,int P[]){
  for(int i = 0;i<M;i++){
    adj[R[i][0]].emplace_back(R[i][1],L[i]);
    adj[R[i][1]].emplace_back(R[i][0],L[i]);
  }
  for(int i = 0;i<N;i++){
    vis[i] = false;
    good[i] = false;
    dp[i] = inf;
  }
  for(int i = 0;i<K;i++){
    dp[P[i]] = 0;
    good[P[i]] = true;
  }
  dfs(0);
  if(!good[0]){
    return -1;
  }else{
    return (int) dp[0];
  }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 2 ms 6492 KB Output is correct
4 Correct 2 ms 6488 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 2 ms 6492 KB Output is correct
7 Correct 2 ms 6488 KB Output is correct
8 Correct 2 ms 6488 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 2 ms 6492 KB Output is correct
4 Correct 2 ms 6488 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 2 ms 6492 KB Output is correct
7 Correct 2 ms 6488 KB Output is correct
8 Correct 2 ms 6488 KB Output is correct
9 Incorrect 3 ms 6748 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 2 ms 6492 KB Output is correct
4 Correct 2 ms 6488 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 2 ms 6492 KB Output is correct
7 Correct 2 ms 6488 KB Output is correct
8 Correct 2 ms 6488 KB Output is correct
9 Incorrect 3 ms 6748 KB Output isn't correct
10 Halted 0 ms 0 KB -