QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#54853#4197. Natural NavigationT3alaadl3k2olyehymn3kWA 2ms3552kbC++1.5kb2022-10-10 22:46:342022-10-10 22:46:36

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-10 22:46:36]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3552kb
  • [2022-10-10 22:46:34]
  • 提交

answer

#include "bits/stdc++.h"

using namespace std;
#define int long long
#define INF 10000000000000

signed main() {
    int n, m, k;
    cin >> n >> m >> k;
    vector<vector<pair<int, pair<int, int>>>> a(n + 1);//from dist color
    map<int, map<int, int>> colN;
    for (int i = 0; i < m; i++) {
        int u, v, w;
        cin >> u >> v >> w;
        int l;
        cin >> l;
        for (int j = 0; j < l; j++) {
            int clr;
            cin >> clr;
            a[v].push_back({u, {w, clr}});
            colN[u][clr]++;
        }
    }
    vector<int> dist(n + 33, INF);
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<>> pq;
    pq.push({0, 1});
    dist[1] = 0;
    map<int, map<int, int>> colG;
    while (!pq.empty()) {
        auto X = pq.top();
        pq.pop();
        if (X.first != dist[X.second])continue;
        for (auto i: a[X.second]) {
            int dis = i.second.first + X.first;
            colG[i.first][i.second.second] = max(colG[i.first][i.second.second], dis);
            colN[i.first][i.second.second]--;
            if (colN[i.first][i.second.second] == 0) {
                if (colG[i.first][i.second.second] < dist[i.first]) {
                    dist[i.first] = colG[i.first][i.second.second];
                    pq.push({colG[i.first][i.second.second], i.first});
                }
            }
        }
    }
    if (dist[n] != INF)
        cout << dist[n] << endl;
    else
        cout << "impossible" << endl;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 3552kb

input:

4 6 2
1 2 6
1 1
1 3 3
1 2
2 3 5
1 2
2 4 8
1 1
3 1 4
2 1 2
3 4 3
1 1

output:

impossible

result:

wrong answer 1st lines differ - expected: '14', found: 'impossible'