QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#467387#4197. Natural Navigationchen_zexingWA 598ms154160kbC++141.6kb2024-07-08 16:01:292024-07-08 16:01:29

Judging History

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

  • [2024-07-08 16:01:29]
  • 评测
  • 测评结果:WA
  • 用时:598ms
  • 内存:154160kb
  • [2024-07-08 16:01:29]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
struct path{
    int to,cost;
    vector <int> v;
};
vector <path> v[500005];
map <int,multiset<long long,greater<long long>>> s[500005];
long long dis[500005];
int vis[500005];
int main(){
    int T = 1;
//    cin >> T;
    while(T--) {
        int n,m,k;
        cin>>n>>m>>k;
        for(int i=1,x,y,w,l;i<=m;i++){
            scanf("%d%d%d%d",&x,&y,&w,&l);
            vector <int> temp;
            for(int j=1,c;j<=l;j++) scanf("%d",&c),temp.push_back(c),s[x][c].insert(LLONG_MAX/10);
            v[y].push_back(path{x,w,temp});
        }
        for(int i=1;i<=n;i++) dis[i]=LLONG_MAX/10;
        dis[n]=0;
        priority_queue <pair<long long,int>,vector<pair<long long,int>>,greater<pair<long long,int>>> q;
        q.push({0,n});
        while(!q.empty()){
            auto temp=q.top();
            q.pop();
            long long d=temp.first;
            int x=temp.second;
            if(vis[x]) continue;
            vis[x]=1;
            for(auto t:v[x]){
                long long td=dis[t.to];
                for(auto c:t.v){
                    assert(s[t.to][c].find(LLONG_MAX/10)!=s[t.to][c].end());
                    s[t.to][c].erase(s[t.to][c].find(LLONG_MAX/10));
                    s[t.to][c].insert(d+t.cost);
//                    cout<<x<<" "<<t.to<<" "<<d+t.cost<<endl;
                    if(*s[t.to][c].begin()<td)
                        dis[t.to]=*s[t.to][c].begin(),q.push({dis[t.to],t.to});
                }
            }
        }
        if(dis[1]==LLONG_MAX/10) puts("impossible");
        else printf("%lld\n",dis[1]);
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 5ms
memory: 42372kb

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

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

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

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

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

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

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

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: 0
Accepted
time: 515ms
memory: 146988kb

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:

172783

result:

ok single line: '172783'

Test #10:

score: 0
Accepted
time: 598ms
memory: 131604kb

input:

1000 393460 1000
423 423 637689
1 427
423 726 460151
1 920
423 311 685370
1 597
423 412 701330
1 553
423 330 717005
1 862
423 676 524095
2 366 411
423 216 69984
1 299
423 272 363386
1 763
423 652 926886
1 928
423 357 607150
1 347
423 927 534335
1 315
423 545 655568
2 267 828
423 842 602690
1 865
423...

output:

33452

result:

ok single line: '33452'

Test #11:

score: 0
Accepted
time: 225ms
memory: 98580kb

input:

2000 484362 2
1289 135 761615
1 2
1289 1163 944919
1 2
1289 507 138396
1 2
1289 1879 154507
1 2
1289 1934 484632
1 2
1289 1049 913244
1 2
1289 626 900547
1 1
1289 1183 718783
1 1
1289 648 250102
1 2
1289 64 202751
1 2
1289 364 916080
1 1
1289 1970 703438
1 2
1289 382 559816
1 1
1289 1232 544698
1 2
...

output:

impossible

result:

ok single line: 'impossible'

Test #12:

score: 0
Accepted
time: 201ms
memory: 95352kb

input:

1000 421412 3
296 81 449614
1 3
296 636 731202
1 3
296 149 645560
1 2
296 560 570799
1 2
296 92 483079
1 3
296 83 65086
1 2
296 239 502528
1 3
296 692 952771
1 1
296 387 27706
1 3
296 489 203962
1 1
296 583 276352
1 3
296 968 443564
2 1 3
296 68 859602
1 2
296 432 245638
1 2
296 294 933292
1 3
296 2...

output:

impossible

result:

ok single line: 'impossible'

Test #13:

score: 0
Accepted
time: 201ms
memory: 93972kb

input:

1000 413799 4
570 396 203345
1 3
570 801 3447
2 2 4
570 393 825231
1 2
570 161 433365
1 4
570 44 855873
1 1
570 127 873092
1 1
570 781 749825
1 3
570 897 334612
1 1
570 953 166340
1 3
570 922 865765
3 1 2 3
570 259 949726
1 2
570 932 770327
1 1
570 640 140986
2 1 4
570 871 92089
1 2
570 326 262958
1...

output:

impossible

result:

ok single line: 'impossible'

Test #14:

score: 0
Accepted
time: 383ms
memory: 98196kb

input:

25000 250000 6
17414 524 2552
2 1 5
6925 13350 4266
2 1 5
21567 1185 10194
2 5 6
6852 11401 5660
2 1 2
4925 10674 1
2 3 6
17895 7429 1
2 4 5
10990 5624 1
2 5 6
17763 9586 4510
2 2 4
3807 23200 1
2 3 6
16899 3423 17559
2 2 3
65 20870 9386
2 1 5
19750 16854 9277
2 2 3
5144 12747 1473
2 2 6
10320 1974 ...

output:

25003

result:

ok single line: '25003'

Test #15:

score: 0
Accepted
time: 391ms
memory: 96580kb

input:

25000 250000 6
9264 24855 1
2 2 5
10001 17614 2782
2 4 5
16769 24107 11599
2 5 6
14392 10268 5803
2 2 4
4593 21267 8734
2 1 4
4656 24084 11510
2 1 5
5357 21697 2724
2 4 5
11922 1206 1525
2 4 5
5664 9582 9415
2 1 6
12899 23693 10228
2 1 5
11271 10752 9059
2 4 5
21469 19200 5355
2 2 5
1939 13213 12197...

output:

25005

result:

ok single line: '25005'

Test #16:

score: 0
Accepted
time: 369ms
memory: 96596kb

input:

25000 250000 6
4151 24847 16676
2 1 3
12906 3823 349
2 2 6
15090 17814 16676
2 1 6
15670 20829 7408
2 4 6
21348 13857 11714
2 4 5
4679 20662 14579
2 2 6
1541 17190 1226
2 4 6
23727 22673 7454
2 2 6
11914 480 11063
2 2 3
13366 13999 3138
2 2 4
18299 668 17996
2 1 3
18541 11685 16126
2 2 5
8748 3304 2...

output:

25004

result:

ok single line: '25004'

Test #17:

score: 0
Accepted
time: 503ms
memory: 154160kb

input:

500000 499999 6
327641 265002 1000000
1 4
335152 364616 1000000
1 6
304056 199957 1000000
1 1
31943 238826 1000000
1 3
467115 226265 1000000
1 1
452304 272411 1000000
1 5
276919 312727 1000000
1 6
35635 101200 1000000
1 5
41182 376552 1000000
1 5
392601 47344 1000000
1 1
74827 378739 1000000
1 6
106...

output:

499999000000

result:

ok single line: '499999000000'

Test #18:

score: 0
Accepted
time: 336ms
memory: 97632kb

input:

25000 250000 6
13556 19067 591829
2 3 5
13774 1699 467303
2 1 6
18569 19613 51894
2 2 6
18343 14076 351259
2 2 3
10229 5323 819364
2 5 6
272 5706 402046
2 1 5
15615 21590 20621
2 1 3
6347 3277 480576
2 2 4
4203 2418 86185
2 4 5
10479 20309 268761
2 2 6
5924 10590 398059
2 3 6
10312 20931 206283
2 1 ...

output:

225325344

result:

ok single line: '225325344'

Test #19:

score: 0
Accepted
time: 308ms
memory: 99196kb

input:

25000 250000 6
17071 15121 372902
2 1 3
19454 14119 396730
2 4 5
7751 13805 168177
2 1 2
24725 16352 676276
2 2 3
23933 13751 232546
2 1 6
12849 12532 464141
2 1 4
13636 17422 220826
2 3 6
10635 21038 219240
2 5 6
8305 8986 956730
2 2 5
223 8232 517076
2 2 5
15528 11798 699196
2 1 6
10409 15785 6823...

output:

224183495

result:

ok single line: '224183495'

Test #20:

score: 0
Accepted
time: 326ms
memory: 97440kb

input:

25000 250000 6
24380 2953 36492
2 1 3
10928 23391 750247
2 2 5
22912 10678 459666
2 1 4
13532 10421 162174
2 1 5
10835 12373 970457
2 1 3
5604 6128 803124
2 2 4
20942 24990 87350
2 2 3
23268 13065 574731
2 4 6
23962 12196 502641
2 3 4
20804 21282 764498
2 4 6
13433 18671 679673
2 3 5
5734 18936 8079...

output:

223635232

result:

ok single line: '223635232'

Test #21:

score: 0
Accepted
time: 378ms
memory: 114064kb

input:

25000 250000 20
15215 9184 424294
2 13 16
8212 14908 454354
2 2 11
4637 10964 478156
2 8 15
1934 16075 246809
2 5 11
2302 23852 510742
2 3 19
6534 23284 731895
2 15 20
8818 14293 384477
2 14 17
10395 22749 690481
2 1 3
3349 3089 616611
2 7 11
12106 12484 720721
2 7 17
12227 20697 868514
2 13 14
9000...

output:

60910058

result:

ok single line: '60910058'

Test #22:

score: 0
Accepted
time: 375ms
memory: 114236kb

input:

25000 250000 20
18936 165 370043
2 10 17
21962 2975 9846
2 15 18
6244 13952 92336
2 13 14
20048 1906 820570
2 6 10
23360 2362 532380
2 15 17
19736 19602 104399
2 14 20
339 2234 212024
2 3 11
20444 24575 666916
2 9 13
14444 3643 813948
2 8 10
22056 24431 173120
2 9 20
12090 23119 964764
2 9 15
15816 ...

output:

57809373

result:

ok single line: '57809373'

Test #23:

score: -100
Wrong Answer
time: 374ms
memory: 114824kb

input:

25000 250000 20
21220 19277 757364
2 7 14
14167 6099 793246
2 1 20
20002 17299 382663
2 14 19
16317 3567 859055
2 16 20
20764 20160 282598
2 2 17
24642 12881 357440
2 15 16
16214 15488 113631
2 8 15
2447 10035 315867
2 8 13
23859 5883 931260
2 11 15
6047 18197 988365
2 14 18
7050 17035 37629
2 1 18
...

output:

57430289

result:

wrong answer 1st lines differ - expected: '57371862', found: '57430289'