제출 #878450

#제출 시각아이디문제언어결과실행 시간메모리
878450nima_aryanToll (BOI17_toll)C++14
100 / 100
2132 ms7948 KiB
#include <bits/stdc++.h>

using namespace std;

#pragma GCC optimize("O3,unroll-loops")

#ifdef LOCAL
#include "algo/debug.h"
#endif

using i64 = long long;

constexpr int inf = 1E9;

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

  int K, N, M, O;
  cin >> K >> N >> M >> O;

  vector<vector<pair<int, int>>> g(N);
  for (int i = 0; i < M; ++i) {
    int a, b;
    cin >> a >> b;
    int t;
    cin >> t;
    g[b].emplace_back(a, t);
  }

  while (O--) {
    int a, b;
    cin >> a >> b;

    if (a > b) {
      cout << -1 << "\n";
      continue;
    }

    vector<int> d(b - a + 1, inf);
    d[0] = 0;

    for (int u = a + 1; u <= b; ++u) {
      for (auto& [v, t] : g[u]) {
        if (v - a >= 0) {
          d[u - a] = min(d[u - a], d[v - a] + t);
        }
      }
    }

    cout << (d.back() < inf ? d.back() : -1) << "\n";
  }

  return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

toll.cpp: In function 'int main()':
toll.cpp:44:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   44 |       for (auto& [v, t] : g[u]) {
      |                  ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...