QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#54853 | #4197. Natural Navigation | T3alaadl3k2olyehymn3k | WA | 2ms | 3552kb | C++ | 1.5kb | 2022-10-10 22:46:34 | 2022-10-10 22:46:36 |
Judging History
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'