답안 #1080862

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1080862 2024-08-29T15:16:22 Z avighna Aesthetic (NOI20_aesthetic) C++17
13 / 100
2000 ms 33084 KB
#include <bits/stdc++.h>

typedef long long ll;

struct To {
  ll v, w;
  ll i;
};

const ll inf = 1e15;

int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);

  ll n, m;
  std::cin >> n >> m;
  std::vector<std::vector<To>> adj(n + 1);
  std::vector<ll> roads(m);
  for (ll i = 0, u, v, w; i < m; ++i) {
    std::cin >> u >> v >> w;
    adj[u].push_back({v, w, i});
    adj[v].push_back({u, w, i});
    roads[i] = w;
  }

  // exclude edge i
  auto sssp = [&](ll i, ll add) {
    std::vector<ll> ans(n + 1, inf);
    std::vector<bool> vis(n + 1);
    std::priority_queue<std::pair<ll, ll>> pq;
    pq.push({0, 1});
    while (!pq.empty()) {
      auto [d, node] = pq.top();
      d *= -1;
      pq.pop();
      if (vis[node]) {
        continue;
      }
      vis[node] = true;
      for (auto [ch, w, cur_i] : adj[node]) {
        if (cur_i == i) {
          w += add;
        }
        if (ans[ch] > d + w) {
          ans[ch] = d + w;
          pq.push({-ans[ch], ch});
        }
      }
    }
    return ans;
  };

  ll def = sssp(-1, 0)[n];
  ll ans = def;
  ll worst_road = roads[m - 1];
  for (ll i = m - 2; i >= 0; --i) {
    ans = std::max(ans, sssp(i, worst_road)[n]);
    worst_road = std::max(worst_road, roads[i]);
  }
  std::cout << ans << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 200 ms 604 KB Output is correct
10 Correct 214 ms 704 KB Output is correct
11 Correct 137 ms 600 KB Output is correct
12 Correct 140 ms 664 KB Output is correct
13 Correct 84 ms 600 KB Output is correct
14 Correct 66 ms 600 KB Output is correct
15 Correct 65 ms 604 KB Output is correct
16 Correct 65 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2045 ms 32208 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2072 ms 33084 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2036 ms 32812 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2036 ms 32812 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 200 ms 604 KB Output is correct
10 Correct 214 ms 704 KB Output is correct
11 Correct 137 ms 600 KB Output is correct
12 Correct 140 ms 664 KB Output is correct
13 Correct 84 ms 600 KB Output is correct
14 Correct 66 ms 600 KB Output is correct
15 Correct 65 ms 604 KB Output is correct
16 Correct 65 ms 604 KB Output is correct
17 Execution timed out 2045 ms 32208 KB Time limit exceeded
18 Halted 0 ms 0 KB -