Submission details
Task:Shortest Routes I
Sender:aalto26fh_003
Submission time:2026-10-04 12:24:31 +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.17 sdetails
#70.17 sdetails
#80.17 sdetails
#90.17 sdetails
#100.17 sdetails
#11ACCEPTED0.10 sdetails
#12ACCEPTED0.07 sdetails
#13ACCEPTED0.01 sdetails
#14ACCEPTED0.08 sdetails
#15ACCEPTED0.07 sdetails
#16--details
#17ACCEPTED0.07 sdetails
#18--details

Compiler report

input/code.cpp: In function 'void dijkstra(long long int)':
input/code.cpp:49:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |         for(int i=0;i<g[u].size() ; i++){
      |                     ~^~~~~~~~~~~~

Code

#include<bits/stdc++.h>
//#include<unordered_set>
// #pragma GCC optimize("Ofast")
using namespace std;
#define int long long
#define die(x) return cout << x << endl, 0
#define FI first
#define SE second
#define all(o) o.begin(), o.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0), cin.tie(0)
#define FILE freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define SZ(x) ((int)(x).size())
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define MP make_pair
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef map<int,int> mpi;
typedef set<int> sti;
typedef vector<pii> vii;
typedef map<pii,int> mpii;
typedef set<pii> stii;
typedef long double ld;
typedef long long ll;
int gcd(int x,int y){ return (!y ? x : gcd(y, x%y)); }
int power(int x, int y) { return (!y ? 1 : power(x, y / 2) * power(x, y / 2) * (y % 2 ? x : 1)); }
int to_int(string sconvert){stringstream geek(sconvert);int xconvert = 0; geek >> xconvert; return xconvert;}
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }
const int MAXN=2e5+30,MAX_LOG=30,MOD=1e9+7,INF=1e17;
const double PI = acos(-1);
int mod(int x) { return (x % MOD + MOD) % MOD; }
int n, m, q;

int d[MAXN];
vii g[MAXN];
int p[MAXN];
void dijkstra(int source) {
    fill(d,d+MAXN,INF);
    priority_queue<pii, vector<pii>, greater<pii> > Q; 
    d[source] = 0;
    Q.push(make_pair(0,source));
    while(!Q.empty()){
        int u = Q.top().second;
        Q.pop();
        for(int i=0;i<g[u].size() ; i++){
            pair<int,int> c=g[u][i];
            int v = c.first;
            int w = c.second;
            if(d[v] > d[u]+w){
                d[v] = d[u]+w;
                p[v]=u;
                Q.push(make_pair(d[v],v));
            }
        }
    }
}


int MAIN(){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b,c;
        cin>>a>>b>>c;
        g[a].PB({b,c});
        g[b].PB({a,c});
    }
    dijkstra(1);
    for(int i=1;i<=n;i++){
        if(d[i]==INF) cout<<-1<<" ";
        else cout<<d[i]<<" ";
    }
    
    return 0;
}

int32_t main(){
    IOS;
    int t=1;
    //cin>>t;
    while(t--)MAIN();
    return 0;
}

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
0 9 11 10 13 14 19 14 16 18 

Feedback: Incorrect character on line 1 col 8: expected "20", got "10"

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
0 7 9 13 7 9 13 14 17 22 

Feedback: Incorrect character on line 1 col 8: expected "17", got "13"

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
0 2 8 1 2 7 16 14 12 13 

Feedback: Incorrect character on line 1 col 5: expected "11", got "8"

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
0 5 9 16 8 10 14 23 23 14 

Feedback: Incorrect character on line 1 col 8: expected "18", got "16"

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
0 8 10 7 11 17 21 12 15 14 

Feedback: Incorrect character on line 1 col 6: expected "16", got "10"

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
0 479659405 1165315262 1673642...

Feedback: Incorrect character on line 1 col 25: expected "1854343862", got "1673642969"

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
0 655556128 1413395076 1714603...

Feedback: Incorrect character on line 1 col 25: expected "1814086787", got "1714603531"

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
0 269736525 626115013 70199222...

Feedback: Incorrect character on line 1 col 55: expected "2030312494", got "1940358435"

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
0 598585836 1267139909 1050043...

Feedback: Incorrect character on line 1 col 25: expected "1803859312", got "1050043909"

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
0 387990617 441010945 92441292...

Feedback: Incorrect character on line 1 col 89: expected "3867716066", got "3081038129"

Test 11

Verdict: ACCEPTED

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
0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

Test 12

Verdict: ACCEPTED

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

correct output
0 1000000000 2000000000 300000...

user output
0 1000000000 2000000000 300000...

Test 13

Verdict: ACCEPTED

input
1 1
1 1 1

correct output
0 

user output
0 

Test 14

Verdict: ACCEPTED

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
0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 ...

Test 15

Verdict: ACCEPTED

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
0 1 2 3 4 5 6 7 8 9 10 11 12 1...

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)

Test 17

Verdict: ACCEPTED

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
0 30010 30010 30010 30010 3001...

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)