QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#54863#4197. Natural NavigationSa3tElSefrWA 584ms54612kbC++1.4kb2022-10-11 00:08:022022-10-11 00:08:03

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-11 00:08:03]
  • 评测
  • 测评结果:WA
  • 用时:584ms
  • 内存:54612kb
  • [2022-10-11 00:08:02]
  • 提交

answer

#include <bits/stdc++.h>

#define ll long long
#define ld  double
using namespace std;

const int N = 5e5 + 5, mod = 998244353;


vector<pair<int, pair<int, int> > > adj[N];



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


    int n, m, k;
    cin >> n >> m >> k;
    map<pair<int, int>, int>  mp;
    for(int i = 0; i < m; i++) {
        int u, v, t, sz;
        cin >> u >> v >> t >> sz;

        for(int j = 0; j < sz; j++) {
            int col;
            cin >> col;
            mp[{u, col}]++;
            adj[v].push_back({col, {u, t}});
        }
    }
    const ll inf = 1e18;
    vector<ll> dis(n + 1, inf);
    vector<ll> tmp(n + 1, 0);
    dis[n] = 0;

    priority_queue<pair<ll, int> > pq;
    pq.push({0, n});
    while((int) pq.size() > 0) {
        ll cost = -pq.top().first;
        int node = pq.top().second;
        pq.pop();
        if(dis[node] != cost) continue;
        for(auto i: adj[node]) {
            int col = i.first, child = i.second.first, w = i.second.second;
            mp[{child, col}]--;
            tmp[child] = max(tmp[child], dis[node] + w);

            if(mp[{child, col}] == 0 && dis[child] > tmp[child]) {
                dis[child] = tmp[child];
                pq.push({-dis[child], child});
            }
        }
    }

    if(dis[1] == inf) cout << "impossible";
    else cout << dis[1];

    return 0;
}





Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 7ms
memory: 15448kb

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: 4ms
memory: 15344kb

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: 15344kb

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: 15448kb

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: 15360kb

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: 15352kb

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: 15272kb

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: 584ms
memory: 54612kb

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'