답안 #955366

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
955366 2024-03-30T08:41:58 Z blackslex 악어의 지하 도시 (IOI11_crocodile) C++17
46 / 100
177 ms 262144 KB
#include "crocodile.h"
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
using pii = pair<ll, ll>;

ll n, m, k;

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
  n = N; m = M; k = K;
  vector<vector<pii>> v(n, vector<pii>());
  for (int i = 0; i < m; i++) v[R[i][0]].emplace_back(R[i][1], L[i]), v[R[i][1]].emplace_back(R[i][0], L[i]);
  vector<bool> ok(n);
  for (int i = 0; i < k; i++) ok[P[i]] = 1;
  vector<int> dp(n);
  function<void(int, int)> dfs = [&] (int cur, int par) {
    bool isleaf = 1;
    vector<int> u;
    for (auto &[x, y]: v[cur]) {
      if (par == x) continue; isleaf = 0;
      dfs(x, cur);
      u.emplace_back(dp[x] + y);
    }
    sort(u.begin(), u.end());
    if (u.size() == 1) dp[cur] = 1e9;
    else if (u.size() > 1) dp[cur] = u[1];
    if (isleaf) dp[cur] = ok[cur] ? dp[cur] : 1e9;
  };
  dfs(0, -1);
  return dp[0];
}

Compilation message

crocodile.cpp: In lambda function:
crocodile.cpp:21:7: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   21 |       if (par == x) continue; isleaf = 0;
      |       ^~
crocodile.cpp:21:31: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   21 |       if (par == x) continue; isleaf = 0;
      |                               ^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 2 ms 4444 KB Output is correct
3 Correct 1 ms 4440 KB Output is correct
4 Correct 3 ms 4440 KB Output is correct
5 Correct 2 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 4440 KB Output is correct
2 Correct 2 ms 4444 KB Output is correct
3 Correct 1 ms 4440 KB Output is correct
4 Correct 3 ms 4440 KB Output is correct
5 Correct 2 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 177 ms 262144 KB Execution killed with signal 9
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 2 ms 4444 KB Output is correct
3 Correct 1 ms 4440 KB Output is correct
4 Correct 3 ms 4440 KB Output is correct
5 Correct 2 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 177 ms 262144 KB Execution killed with signal 9
10 Halted 0 ms 0 KB -