# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
527779 |
2022-02-18T09:20:27 Z |
1ne |
Autobus (COCI22_autobus) |
C++14 |
|
0 ms |
0 KB |
#include<bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,m;cin>>n>>m;
vector<vector<int64_t>>dist(n,vector<int64_t>(n,1e15));
vector<vector<set<pair<int64_t,int64_t>>>>arr(n,vector<set<pair<int64_t,int64_t>>>(n));
for (int i = 0;i<m;++i){
int64_t x,y,z;cin>>x>>y>>z;
--x;
--y;
dist[x][y] = min(dist[x][y],z);
}
for (int i = 0;i<n;++i){
for (int j = 0;j<n;++j){
if (i!=j&&dist[i][j]!=1e15){
arr[i][j].insert({dist[i][j],1});
}
}
}
int64_t kk,q;cin>>kk>>q;
for (int i = 0;i<n;++i){
for (int j = 0;j<n;++j){
for (int k = 0;k<n;++k){
int64_t mindist = 1e15,mink=1e15;
for (auto x:arr[j][k]){
if (x.first<mindist){
mindist = x.first;
}
if (x.second<mink){
mink = x.second;
}
}
int64_t mink = 1e15;
for (auto x:arr[j][i]){
for (auto y:arr[i][k]){
if (x.second + y.second<=min(mink,kk)){
arr[j][k].insert({x.first + y.first,x.second + y.second});
mink = min(mink,x.second + y.second);
}
}
}
}
}
}
for (int i = 0;i<q;++i){
int x,y;cin>>x>>y;
--x;
--y;
if (x==y){
cout<<0<<'\n';
continue;
}
if (arr[x][y].empty()){
cout<<-1<<'\n';
}
else{
auto z = *arr[x][y].begin();
cout<<z.first<<'\n';
}
}
return 0;}
Compilation message
Main.cpp: In function 'int main()':
Main.cpp:38:12: error: redeclaration of 'int64_t mink'
38 | int64_t mink = 1e15;
| ^~~~
Main.cpp:29:27: note: 'int64_t mink' previously declared here
29 | int64_t mindist = 1e15,mink=1e15;
| ^~~~