#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define vi vector<int>
#define ve vector
#define ll long long
#define vl vector<ll>
#define vll vector<pair<ll,ll>>
#define onbit __builtin_popcount
#define ii pair<int,int>
#define vvi vector<vi>
#define vii vector<ii>
#define gii greater<ii>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF 1e18
#define eps 1e-7
#define eps1 1e-2
#define optimise ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MAX_A 1e5+5
using namespace std;
using namespace __gnu_pbds;
template <class T>
using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int MOD = 1e9+7;
const int nax = 1e5+5;
const int MAX_VAL = 1e9;
double PI=3.14159265359;
int arx[8]={1,1,0,-1,-1,-1, 0, 1};
int ary[8]={0,1,1, 1, 0,-1,-1,-1};
typedef complex<int> Point;
#define X real()
#define Y imag()
template<typename T, typename U>
ostream & operator << (ostream &out, const pair<T, U> &c) {
out << c.first << ' ' << c.second;
return out;
}
template<typename T>
ostream & operator << (ostream &out, vector<T> &v) {
const int sz = v.size();
for (int i = 0; i < sz; i++) {
if (i) out << ' ';
out << v[i];
}
return out;
}
template<typename T>
istream & operator >> (istream &in, vector<T> &v) {
for (T &x : v) in >> x;
return in;
}
/*void setIO(string s) {
freopen((s + ".in").c_str(), "r", stdin);
freopen((s + ".out").c_str(), "w", stdout);
}*/
vector<pair<int,int>> adj[nax];
vector<int> dis(nax);
int dp[nax];
vector<bool> tab(nax);
bool vis[nax];
ll travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
int n = N;
vi bahma(K);
vl a(n,1e15);
vl b(n,1e15);
memset(dp,-1,sizeof dp);
for(int i = 0; i < M; i++) {
int x = R[i][0];
int y = R[i][1];
int t = L[i];
bahma[i]=L[i];
tab[L[i]]=1;
adj[x].pb({y, t});
adj[y].pb({x, t});
}
priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<>> pq;
for (int i = 0; i < K; ++i)
{
pq.push({0,bahma[i]});
}
while(!pq.empty())
{
ll x=pq.top().fi;
int y=pq.top().se;
pq.pop();
if (y==0)
{
return x;
}
if (vis[y]) continue;
vis[y]=true;
for(auto u:adj[y])
{
int node=u.fi;
int d=u.se;
if (a[node]>d+x){
b[node]=a[node];
a[node]=d+x;
}else if(b[node]>d+x){
b[node]=d+x;
}
pq.push({b[node],node});
}
}
}
/*int main(){
optimise;
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
//setIO("pump");
}*/
Compilation message
crocodile.cpp: In function 'long long int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:67:15: warning: control reaches end of non-void function [-Wreturn-type]
67 | vi bahma(K);
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
7 ms |
6740 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
7 ms |
6740 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
7 ms |
6740 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |