Submission #701791

#TimeUsernameProblemLanguageResultExecution timeMemory
701791Do_you_copyCeste (COCI17_ceste)C++17
160 / 160
584 ms25336 KiB
#include <bits/stdc++.h> #define fi first #define se second #define faster ios_base::sync_with_stdio(0); cin.tie(0); #define pb push_back using namespace std; using ll = long long; using pii = pair <int, int>; const int thrs = 4e6; const int maxN = 2004 + 1; const ll inf = 0x3f3f3f3f3f3f3f3f; //const int Mod = int n, m; struct TEdge{ ll u, t, c; }; vector <TEdge> adj[maxN]; struct TPQ{ ll u, t, c; bool operator < (const TPQ &other) const{ if (c == other.c) return t > other.t; return c > other.c; } }; ll d[maxN]; int t[maxN]; void Init(){ cin >> n >> m; for (int i = 1; i <= m; ++i){ int u, v, t, c; cin >> u >> v >> t >> c; adj[u].pb({v, t, c}); adj[v].pb({u, t, c}); } priority_queue <TPQ> PQ; PQ.push({1, 0, 0}); memset(d, 0x3f, sizeof(d)); memset(t, 0x3f, sizeof(t)); d[1] = t[1] = 0; while (!PQ.empty()){ auto u = PQ.top(); PQ.pop(); d[u.u] = min(d[u.u], u.t * u.c); if (t[u.u] < u.t) continue; t[u.u] = u.t; for (auto i: adj[u.u]){ if (u.t + i.t > thrs) continue; PQ.push({i.u, u.t + i.t, u.c + i.c}); } } for (int i = 2; i <= n; ++i){ if (d[i] == inf){ cout << -1 << "\n"; } else cout << d[i] << "\n"; } } #define taskname "test" signed main(){ faster if (fopen(taskname ".inp", "r")){ freopen(taskname ".inp", "r", stdin); freopen(taskname ".out", "w", stdout); } int tt = 1; //cin >> tt; while (tt--){ Init(); } if (fopen("timeout.txt", "r")){ ofstream timeout("timeout.txt"); cerr << "Time elapsed: " << signed(double(clock()) / CLOCKS_PER_SEC * 1000) << "ms\n"; timeout << signed(double(clock()) / CLOCKS_PER_SEC * 1000); timeout.close(); } }

Compilation message (stderr)

ceste.cpp: In function 'int main()':
ceste.cpp:67:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   67 |         freopen(taskname ".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ceste.cpp:68:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   68 |         freopen(taskname ".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...