제출 #1014429

#제출 시각아이디문제언어결과실행 시간메모리
1014429tanishaDrivers (BOI24_drivers)C++14
0 / 100
2086 ms6096 KiB
#include <iostream>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;

const int MAX_N = 200001;

vector<pair<int, int>> graph[MAX_N];
bool visited[MAX_N];

bool can_reach_safely(int start, int end, int max_time) {
    memset(visited, 0, sizeof(visited));
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;

    pq.push({0, start});

    while (!pq.empty()) {
        int time = pq.top().first;
        int city = pq.top().second;
        pq.pop();

        if (city == end) return true;
        if (visited[city]) continue;
        visited[city] = true;

        for (const auto& [next_city, travel_time] : graph[city]) {
            if (travel_time > max_time) continue;
            int new_time = time + travel_time;
            pq.push({(new_time <= max_time) ? new_time : travel_time, next_city});
        }
    }

    return false;
}

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

    int N, M, U;
    cin >> N >> M >> U;

    for (int i = 0; i < M; ++i) {
        int x, y, t;
        cin >> x >> y >> t;
        graph[x].emplace_back(y, t);
        graph[y].emplace_back(x, t);
    }

    for (int i = 0; i < U; ++i) {
        int a, b, p;
        cin >> a >> b >> p;
        cout << (can_reach_safely(a, b, p) ? "TAIP\n" : "NE\n");
    }

    return 0;
}

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

Main.cpp: In function 'bool can_reach_safely(int, int, int)':
Main.cpp:28:26: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   28 |         for (const auto& [next_city, travel_time] : graph[city]) {
      |                          ^
#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...