# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
749055 |
2023-05-27T09:35:59 Z |
onebit1024 |
Ceste (COCI17_ceste) |
C++17 |
|
1901 ms |
41484 KB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define all(c) c.begin(), c.end()
#define endl "\n"
const double PI=3.141592653589;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cerr << "LINE(" << __LINE__ << ") -> " <<"[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
struct node{
int v,t,c;
};
void solve()
{
int n,m;
cin >> n >> m;
vector<vector<node>>adj(n+1);
for(int i = 1;i<=m;++i){
int u,v,b,d; // t,c
cin >> u >> v >> b >> d;
adj[u].pb({v,b,d});
adj[v].pb({u,b,d});
}
priority_queue<vector<int>,vector<vector<int>>,greater<vector<int>>>pq;
vector<int>res(n+1,1e18);
res[1] = 0;
int mm = 2000*3000;
pq.push({0,0,1});
vector<int>maxt(n+1,1e18);
while(!pq.empty()){
int u = pq.top()[2], c = pq.top()[0],t = pq.top()[1];
res[u] = min(res[u], c*t);
pq.pop();
if(t>maxt[u])continue;
maxt[u] = t;
for(auto &[v,T,C] : adj[u]){
int nc = C+c,nt = T+t;
if(nt>mm)continue;
pq.push({nc,nt,v});
}
}
for(int i = 2;i<=n;++i){
if(res[i]>=1e18)res[i] = -1;
cout << res[i] << endl;
}
}
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
int T=1;
for(int i = 1;i<=T;++i)
{
// cout << "Case #" << i << ": ";
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
508 KB |
Output is correct |
2 |
Correct |
8 ms |
596 KB |
Output is correct |
3 |
Correct |
8 ms |
852 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
75 ms |
2816 KB |
Output is correct |
2 |
Correct |
168 ms |
5524 KB |
Output is correct |
3 |
Correct |
124 ms |
5664 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
351 ms |
5608 KB |
Output is correct |
2 |
Correct |
1901 ms |
41484 KB |
Output is correct |
3 |
Correct |
10 ms |
960 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
116 ms |
1660 KB |
Output is correct |
2 |
Correct |
981 ms |
20932 KB |
Output is correct |
3 |
Correct |
18 ms |
652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
439 ms |
1668 KB |
Output is correct |
2 |
Correct |
546 ms |
7176 KB |
Output is correct |
3 |
Correct |
434 ms |
6556 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
437 ms |
6684 KB |
Output is correct |
2 |
Correct |
389 ms |
5908 KB |
Output is correct |
3 |
Correct |
623 ms |
7360 KB |
Output is correct |