Submission #512465

#TimeUsernameProblemLanguageResultExecution timeMemory
512465Killer2501Ceste (COCI17_ceste)C++14
160 / 160
371 ms17680 KiB
#include <bits/stdc++.h> #define ll long long #define ld long double #define ull unsigned long long #define pb push_back #define pll pair<ll, ll> #define pii pair<int, int> #define fi first #define se second using namespace std; const int N = 2e5+5; const int M = (1<<17); const ll inf = 1e15; const int mod = 1e9+7; int n, t, k, a[N], c[N], d[N], m; ll ans, tong, b[N]; string s; struct node { int id, x, y; node(){} node(int _id, int _x, int _y) { id = _id; x = _x; y = _y; } bool operator < (const node& u) const { return x > u.x; } }; vector<node> adj[N]; void sol() { cin >> n >> m; while(m -- > 0) { int x, y, t, c; cin >> x >> y >> t >> c; adj[x].pb(node(y, t, c)); adj[y].pb(node(x, t, c)); } fill_n(b, n+1, inf); fill_n(d, n+1, mod); priority_queue< node > pq; pq.push(node(1, 0, 0)); while(!pq.empty()) { node u = pq.top(); pq.pop(); //cout << u.id <<" "<<u.x <<" "<<u.y <<'\n'; if(u.y > d[u.id])continue; d[u.id] = u.y; b[u.id] = min(b[u.id], 1ll * u.x * u.y); for(node v: adj[u.id]) { pq.push(node(v.id, u.x+v.x, u.y+v.y)); } } for(int i = 2; i <= n; i ++) { if(b[i] == inf)cout << -1 << '\n'; else cout << b[i] << '\n'; } } int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); #define task "test" if(fopen(task".inp", "r")) { freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } int ntest = 1; //cin >> ntest; while(ntest -- > 0) sol(); }

Compilation message (stderr)

ceste.cpp: In function 'int main()':
ceste.cpp:75:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   75 |   freopen(task".inp", "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
ceste.cpp:76:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   76 |   freopen(task".out", "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...