Submission #1074443

#TimeUsernameProblemLanguageResultExecution timeMemory
1074443cpptowinCeste (COCI17_ceste)C++17
96 / 160
175 ms2284 KiB
#include <bits/stdc++.h> #define fo(i, d, c) for (int i = d; i <= c; i++) #define fod(i, c, d) for (int i = c; i >= d; i--) #define maxn 1000010 #define N 5010 #define fi first #define se second #define pb emplace_back #define en cout << "\n"; #define bitcount(x) __builtin_popcountll(x) #define pii pair<int, int> #define vii vector<pii> #define lb(x) x & -x #define bit(i, j) ((i >> j) & 1) #define offbit(i, j) (i ^ (1LL << j)) #define onbit(i, j) (i | (1LL << j)) #define vi vector<int> #define all(x) x.begin(), x.end() #define ss(x) (int)x.size() template <typename T1, typename T2> bool minimize(T1 &a, T2 b) { if (a > b) { a = b; return true; } return false; } template <typename T1, typename T2> bool maximize(T1 &a, T2 b) { if (a < b) { a = b; return true; } return false; } using namespace std; const int nsqrt = 450; const int mod = 1e9 + 7; void add(int &x, int k) { x += k; x %= mod; if(x < 0) x += mod; } void del(int &x, int k) { x -= k; x %= mod; if(x < 0) x += mod; } int n,m; long long minf[N],mint[N]; vector<array<int,3>> ke[N]; main() { #define name "TASK" if (fopen(name ".inp", "r")) { freopen(name ".inp", "r", stdin); freopen(name ".out", "w", stdout); } ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> m; fo(i,1,m) { int u,v,t,c; cin >> u >> v >> t >> c; ke[u].push_back({v,t,c}); ke[v].push_back({u,t,c}); } priority_queue<array<int,3>,vector<array<int,3>>,greater<array<int,3>>>q; fo(i,2,n) minf[i] = mint[i] = 1e18; q.push({0,0,1}); int lim = 2000 * 3000; while(ss(q)) { auto [du,dt,u] = q.top(); minimize(minf[u],du * dt); q.pop(); if(mint[u] < dt) continue; mint[u] = dt; for(auto [v,t,c] : ke[u]) { if(dt + t <= lim) q.push({du + c,dt + t,v}); } } fo(i,2,n) cout << (minf[i] >= 1e18 ? -1 : minf[i]) << '\n'; }

Compilation message (stderr)

ceste.cpp:58:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   58 | main()
      | ^~~~
ceste.cpp: In function 'int main()':
ceste.cpp:63:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   63 |         freopen(name ".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
ceste.cpp:64:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   64 |         freopen(name ".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...