답안 #999383

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
999383 2024-06-15T11:53:43 Z Mr_Husanboy 악어의 지하 도시 (IOI11_crocodile) C++17
46 / 100
145 ms 262144 KB
#include "crocodile.h"
#include <bits/stdc++.h>
 
using namespace std;
#define ll long long
 
template<typename T>
int len(T &a){return a.size();}
const int inf = 1e9 + 1;
 
int travel_plan(int n, int m, int r[][2], int L[], int K, int P[])
{
  vector<vector<pair<int,int>>> g(n);
  for(int i = 0; i < m; i ++){
    g[r[i][0]].push_back({r[i][1], L[i]});
    g[r[i][1]].push_back({r[i][0], L[i]});
  }
  vector<int> ex(n);
  for(int i = 0; i < K; i ++) ex[P[i]] = 1;
 
  vector<long long> dis(n);
 
  auto dfs = [&](auto &dfs, int i, int p = -1)->ll{
    if(ex[i]) return 0;
    vector<ll> res;
    for(auto [u, w] : g[i]){
      if(u == p) continue;
      res.push_back(dfs(dfs, u, i) + w);
    }
    
    if(len(res) < 2) return inf;
    sort(res.begin(), res.end());
    return res[1];
  };
 
  return dfs(dfs, 0);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 0 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 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 0 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4700 KB Output is correct
9 Runtime error 145 ms 262144 KB Execution killed with signal 9
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 0 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4700 KB Output is correct
9 Runtime error 145 ms 262144 KB Execution killed with signal 9
10 Halted 0 ms 0 KB -