Submission details
Task:Shortest Routes I
Sender:aalto26fh_024
Submission time:2026-10-03 14:45:34 +0300
Language:C++ (C++20)
Status:READY
Result:
Test results
testverdicttime
#10.01 sdetails
#20.01 sdetails
#30.01 sdetails
#40.01 sdetails
#50.01 sdetails
#60.01 sdetails
#70.01 sdetails
#80.01 sdetails
#90.01 sdetails
#100.01 sdetails
#110.01 sdetails
#120.01 sdetails
#130.01 sdetails
#140.01 sdetails
#150.01 sdetails
#160.01 sdetails
#170.01 sdetails
#180.01 sdetails

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:36:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |     freopen("file.inp","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
input/code.cpp:37:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |     freopen("file.out","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~

Code

#include <bits/stdc++.h>
#define ll long long
#define ii pair<long long,int>
#define pb push_back
#define fi first
#define se second
using namespace std;
const int N=2e5+3;
const ll inf=1e18;
ll dist[N];
int n,m,par[N];
vector<ii>g[N];
void dijk() {
    priority_queue<ii, vector<ii>, greater<ii>>q;
    for (int i=1; i<=n; i++) {dist[i]=inf; par[i]=i;}
    dist[1]=0;
    par[1]=-1;
    q.push({dist[1],1});
    while (!q.empty()) {
        int node=q.top().se;
        ll cost = q.top().fi;
        q.pop();
        if (cost>dist[node]) continue;
        for (auto v:g[node]) {
            if (dist[v.se]>dist[node]+v.fi) {
                dist[v.se]=dist[node]+v.fi;
                par[v.se]=node;
                q.push({dist[v.se],v.se});
            }
        }
    }
}
vector<int>ans;
int main() {
    ios::sync_with_stdio(0);
    freopen("file.inp","r",stdin);
    freopen("file.out","w",stdout);
    cin.tie(0);
    cin >> n >> m;
    for (int i=1; i<=m; i++) {
        int x,y;
        ll w;
        cin >> x >> y >> w;
        g[x].pb({w,y});
        // g[y].pb({w,x});
    }
    dijk();
    for (int i=1; i<=n; i++) cout << dist[i] << ' ';
}

Test details

Test 1

Verdict:

input
10 20
8 5 1
9 10 2
7 9 8
9 8 8
...

correct output
0 9 11 20 13 14 19 29 27 29 

user output
(empty)

Feedback: Output is shorter than expected

Test 2

Verdict:

input
10 20
5 6 4
5 1 7
7 4 4
7 8 1
...

correct output
0 7 9 17 15 17 21 22 25 30 

user output
(empty)

Feedback: Output is shorter than expected

Test 3

Verdict:

input
10 20
1 4 1
4 2 1
9 10 1
1 2 4
...

correct output
0 2 11 1 2 7 16 18 12 13 

user output
(empty)

Feedback: Output is shorter than expected

Test 4

Verdict:

input
10 20
6 3 5
7 5 8
5 1 8
8 9 5
...

correct output
0 5 9 18 22 10 14 23 27 36 

user output
(empty)

Feedback: Output is shorter than expected

Test 5

Verdict:

input
10 20
8 9 3
2 3 8
10 5 3
2 5 3
...

correct output
0 8 16 18 11 17 24 23 16 26 

user output
(empty)

Feedback: Output is shorter than expected

Test 6

Verdict:

input
100000 200000
18000 18001 426710313
73018 73012 558438094
87726 87671 355171790
53170 53171 869493690
...

correct output
0 479659405 1165315262 1854343...

user output
(empty)

Feedback: Output is shorter than expected

Test 7

Verdict:

input
100000 200000
26504 26450 258578924
49543 49544 28958186
75174 75175 89459846
39175 39228 119699475
...

correct output
0 655556128 1413395076 1814086...

user output
(empty)

Feedback: Output is shorter than expected

Test 8

Verdict:

input
100000 200000
39477 39413 773046299
69758 69759 558754983
23279 23280 142570619
61416 61479 874921013
...

correct output
0 269736525 626115013 70199222...

user output
(empty)

Feedback: Output is shorter than expected

Test 9

Verdict:

input
100000 200000
76662 76636 844365635
73339 73342 755006676
89878 89879 396562588
18801 18781 954807004
...

correct output
0 598585836 1267139909 1803859...

user output
(empty)

Feedback: Output is shorter than expected

Test 10

Verdict:

input
100000 200000
11724 11725 818399968
33244 33197 722525474
65530 65531 483965413
62405 62454 199581867
...

correct output
0 387990617 441010945 92441292...

user output
(empty)

Feedback: Output is shorter than expected

Test 11

Verdict:

input
100000 200000
1 2 1
1 3 1
1 4 1
1 5 1
...

correct output
0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

user output
(empty)

Feedback: Output is shorter than expected

Test 12

Verdict:

input
100000 99999
1 2 1000000000
2 3 1000000000
3 4 1000000000
4 5 1000000000
...

correct output
0 1000000000 2000000000 300000...

user output
(empty)

Feedback: Output is shorter than expected

Test 13

Verdict:

input
1 1
1 1 1

correct output
0 

user output
(empty)

Feedback: Output is shorter than expected

Test 14

Verdict:

input
99999 149997
1 2 1
2 3 1
3 4 1
4 5 1
...

correct output
0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 ...

user output
(empty)

Feedback: Output is shorter than expected

Test 15

Verdict:

input
99997 149994
1 3 3
3 5 3
5 7 3
7 9 3
...

correct output
0 1 2 3 4 5 6 7 8 9 10 11 12 1...

user output
(empty)

Feedback: Output is shorter than expected

Test 16

Verdict:

input
60003 120000
1 2 30010
1 3 30010
1 4 30010
1 5 30010
...

correct output
0 30010 30010 30010 30010 3001...

user output
(empty)

Feedback: Output is shorter than expected

Test 17

Verdict:

input
60003 120000
1 2 30010
1 3 30010
1 4 30010
1 5 30010
...

correct output
0 30010 30010 30010 30010 3001...

user output
(empty)

Feedback: Output is shorter than expected

Test 18

Verdict:

input
100000 149997
1 50000 99997
1 49999 99995
1 49998 99993
1 49997 99991
...

correct output
0 1 3 5 7 9 11 13 15 17 19 21 ...

user output
(empty)

Feedback: Output is shorter than expected