QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#54851#4197. Natural NavigationT3alaadl3k2olyehymn3kWA 1715ms83328kbC++1.5kb2022-10-10 22:38:112022-10-10 22:38:13

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:38:13]
  • 评测
  • 测评结果:WA
  • 用时:1715ms
  • 内存:83328kb
  • [2022-10-10 22:38:11]
  • 提交

answer

#include "bits/stdc++.h"

using namespace std;
#define int long long
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, -1);
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<>> pq;
    pq.push({0, n});
    dist[n] = 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) {
                int new_d = colG[i.first][i.second.second];
                if (colG[i.first][i.second.second] < dist[i.first] or dist[i.first] == -1) {
                    dist[i.first] = max(dist[i.first], colG[i.first][i.second.second]);
                    pq.push({new_d, i.first});
                }
            }
        }
    }
    if (~dist[1])
        cout << dist[1] << endl;
    else
        cout << "impossible" << endl;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3632kb

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:

14

result:

ok single line: '14'

Test #2:

score: 0
Accepted
time: 2ms
memory: 3704kb

input:

3 4 3
1 2 300
2 1 2
2 1 2000
2 3 1
1 3 80
2 2 1
2 2 42
1 2

output:

impossible

result:

ok single line: 'impossible'

Test #3:

score: 0
Accepted
time: 1ms
memory: 3716kb

input:

3 2 3
1 2 1
3 1 2 3
1 3 1
2 1 2

output:

impossible

result:

ok single line: 'impossible'

Test #4:

score: 0
Accepted
time: 2ms
memory: 3664kb

input:

4 5 1
1 4 1
1 1
4 3 1
1 1
3 2 1
1 1
2 1 1
1 1
1 3 1
1 1

output:

impossible

result:

ok single line: 'impossible'

Test #5:

score: 0
Accepted
time: 2ms
memory: 3492kb

input:

2 2 3
1 2 3
3 1 2 3
1 2 4
3 1 2 3

output:

4

result:

ok single line: '4'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3492kb

input:

10 12 3
4 4 5
1 1
1 7 5
1 1
1 2 5
1 1
8 4 2
1 1
8 10 5
1 1
6 8 2
1 2
6 5 1
1 2
6 10 7
1 3
5 5 8
1 2
7 1 5
1 1
2 1 6
1 1
2 8 1
1 1

output:

impossible

result:

ok single line: 'impossible'

Test #7:

score: 0
Accepted
time: 2ms
memory: 3632kb

input:

10 19 3
2 2 5
1 2
2 9 4
1 1
2 10 7
1 3
2 4 4
1 3
3 1 9
1 3
5 3 3
1 1
9 3 5
1 2
9 5 10
1 1
9 9 8
1 1
9 6 3
1 3
8 3 6
2 1 3
10 8 8
1 3
10 1 4
1 1
1 9 5
1 1
4 2 2
1 3
4 3 3
1 1
6 9 4
1 2
6 8 4
1 2
6 4 8
1 3

output:

impossible

result:

ok single line: 'impossible'

Test #8:

score: 0
Accepted
time: 2ms
memory: 3552kb

input:

10 40 3
4 4 3
2 2 3
4 6 1
1 3
4 10 4
1 2
4 2 4
1 2
4 7 5
2 1 3
6 8 2
2 1 2
6 10 7
1 3
6 2 5
2 2 3
8 10 7
1 3
8 1 10
1 2
9 8 1
1 1
9 10 7
1 1
9 2 10
2 2 3
9 5 9
1 1
10 4 1
1 3
10 6 5
1 1
10 9 10
1 1
10 2 5
1 2
10 1 4
1 2
10 7 9
1 1
2 6 6
1 2
2 8 3
1 3
2 9 8
1 2
2 2 4
2 1 2
2 5 8
1 2
2 7 3
1 1
5 2 1
1...

output:

39

result:

ok single line: '39'

Test #9:

score: -100
Wrong Answer
time: 1715ms
memory: 83328kb

input:

10000 498740 1000
7756 7812 146482
1 738
7756 4571 581789
1 497
7756 1367 703256
1 674
7756 8199 491446
1 238
7756 6114 941752
1 26
7756 8739 775363
1 30
7756 2619 313750
1 327
7756 7187 113027
1 268
7756 6943 91064
1 366
7756 4027 565567
1 863
7756 5210 613674
1 45
7756 2625 693644
1 468
7756 5013 ...

output:

271607

result:

wrong answer 1st lines differ - expected: '172783', found: '271607'