Submission #783179

# Submission time Handle Problem Language Result Execution time Memory
783179 2023-07-14T16:58:03 Z 1075508020060209tc Toll (BOI17_toll) C++14
46 / 100
3000 ms 17228 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define X first
#define Y second
int K;int n;int m;int O;
vector<pair<int,int>>e[500005];
int dis0[500005];
int dis[500005];int vis[500005];


void dijkstera(int st){
for(int i=0;i<=n;i++){
    dis[i]=1e18;
}
dis[st]=0;
for(int i=st;i<=n-1;i++){
    for(int j=0;j<e[i].size();j++){
        int w=e[i][j].second;
        int v=e[i][j].first;
        dis[v]=min(dis[v],dis[i]+w);
    }
}
}

int ot(int v){
if(v>=1e18){
    return -1;
}
return v;
}

signed main(){
cin.tie(0);
ios_base::sync_with_stdio(0);
cin>>K>>n>>m>>O;
for(int i=1;i<=m;i++){
    int a;int b;int t;
    cin>>a>>b>>t;
    e[a].push_back({b,t});
}
dijkstera(0);
for(int i=0;i<=n;i++){
    dis0[i]=dis[i];
}
while(O--){
    int a;int b;
    cin>>a>>b;
    if(a==-1){
        cout<<ot(dis0[b])<<endl;
    }else{
        dijkstera(a);
        cout<<ot(dis[b])<<endl;
    }


}

}

Compilation message

toll.cpp: In function 'void dijkstera(long long int)':
toll.cpp:18:18: 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]
   18 |     for(int j=0;j<e[i].size();j++){
      |                 ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1489 ms 14472 KB Output is correct
2 Correct 7 ms 11988 KB Output is correct
3 Correct 6 ms 11988 KB Output is correct
4 Correct 6 ms 11988 KB Output is correct
5 Correct 9 ms 12116 KB Output is correct
6 Correct 9 ms 12116 KB Output is correct
7 Correct 11 ms 12116 KB Output is correct
8 Correct 1493 ms 14448 KB Output is correct
9 Correct 1441 ms 14368 KB Output is correct
10 Correct 398 ms 12880 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2944 ms 15544 KB Output is correct
2 Correct 8 ms 11988 KB Output is correct
3 Correct 6 ms 11988 KB Output is correct
4 Correct 6 ms 11988 KB Output is correct
5 Correct 6 ms 11988 KB Output is correct
6 Correct 6 ms 11988 KB Output is correct
7 Correct 52 ms 12116 KB Output is correct
8 Correct 52 ms 12176 KB Output is correct
9 Correct 2064 ms 14556 KB Output is correct
10 Execution timed out 3039 ms 16956 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 11988 KB Output is correct
2 Correct 6 ms 11988 KB Output is correct
3 Correct 5 ms 11988 KB Output is correct
4 Correct 5 ms 11988 KB Output is correct
5 Correct 5 ms 11988 KB Output is correct
6 Correct 6 ms 12116 KB Output is correct
7 Correct 7 ms 12372 KB Output is correct
8 Correct 7 ms 12192 KB Output is correct
9 Correct 7 ms 12116 KB Output is correct
10 Correct 33 ms 14376 KB Output is correct
11 Correct 63 ms 15308 KB Output is correct
12 Correct 66 ms 16716 KB Output is correct
13 Correct 68 ms 17128 KB Output is correct
14 Correct 60 ms 16016 KB Output is correct
15 Correct 43 ms 14524 KB Output is correct
16 Correct 49 ms 14460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 11988 KB Output is correct
2 Correct 6 ms 11988 KB Output is correct
3 Correct 5 ms 11988 KB Output is correct
4 Correct 5 ms 11988 KB Output is correct
5 Correct 5 ms 11988 KB Output is correct
6 Correct 6 ms 12116 KB Output is correct
7 Correct 7 ms 12372 KB Output is correct
8 Correct 7 ms 12192 KB Output is correct
9 Correct 7 ms 12116 KB Output is correct
10 Correct 33 ms 14376 KB Output is correct
11 Correct 63 ms 15308 KB Output is correct
12 Correct 66 ms 16716 KB Output is correct
13 Correct 68 ms 17128 KB Output is correct
14 Correct 60 ms 16016 KB Output is correct
15 Correct 43 ms 14524 KB Output is correct
16 Correct 49 ms 14460 KB Output is correct
17 Correct 616 ms 15396 KB Output is correct
18 Correct 6 ms 12040 KB Output is correct
19 Correct 6 ms 11992 KB Output is correct
20 Correct 6 ms 11988 KB Output is correct
21 Correct 5 ms 11988 KB Output is correct
22 Correct 6 ms 11988 KB Output is correct
23 Correct 17 ms 12116 KB Output is correct
24 Correct 18 ms 12176 KB Output is correct
25 Correct 22 ms 12224 KB Output is correct
26 Correct 20 ms 12208 KB Output is correct
27 Correct 426 ms 14432 KB Output is correct
28 Correct 822 ms 16820 KB Output is correct
29 Correct 813 ms 17228 KB Output is correct
30 Correct 891 ms 16020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1489 ms 14472 KB Output is correct
2 Correct 7 ms 11988 KB Output is correct
3 Correct 6 ms 11988 KB Output is correct
4 Correct 6 ms 11988 KB Output is correct
5 Correct 9 ms 12116 KB Output is correct
6 Correct 9 ms 12116 KB Output is correct
7 Correct 11 ms 12116 KB Output is correct
8 Correct 1493 ms 14448 KB Output is correct
9 Correct 1441 ms 14368 KB Output is correct
10 Correct 398 ms 12880 KB Output is correct
11 Correct 2944 ms 15544 KB Output is correct
12 Correct 8 ms 11988 KB Output is correct
13 Correct 6 ms 11988 KB Output is correct
14 Correct 6 ms 11988 KB Output is correct
15 Correct 6 ms 11988 KB Output is correct
16 Correct 6 ms 11988 KB Output is correct
17 Correct 52 ms 12116 KB Output is correct
18 Correct 52 ms 12176 KB Output is correct
19 Correct 2064 ms 14556 KB Output is correct
20 Execution timed out 3039 ms 16956 KB Time limit exceeded
21 Halted 0 ms 0 KB -