제출 #1037801

#제출 시각아이디문제언어결과실행 시간메모리
1037801tradzRobot (JOI21_ho_t4)C++14
0 / 100
44 ms50820 KiB
#include <bits/stdc++.h> #define For(i,a,b) for(int i = a; i <= b; i++) #define Ford(i,a,b) for(int i = a; i >= b; i--) #define ll long long #define ii pair<ll,ll> #define fi first #define se second #define all(v) v.begin(),v.end() #define RRH(v) v.resize(unique(all(v)) - v.begin()) using namespace std; const int N = 1e6+7; const int M = 1e9+7; const ll oo = 1e18; int n, m; ll d[N]; struct data { int v, c;ll p; }; vector<data> g[N]; void dij() { For (i, 2, n) d[i] = oo; d[1] = 0; priority_queue<ii, vector<ii>, greater<ii>> q; q.push({0ll, 1}); while (q.size() > 0) { ii k = q.top(); q.pop(); if (d[k.se] != k.fi) continue; unordered_map<ll,ll> ma, min_c; for (auto x: g[k.se]) min_c[x.c] = oo, ma[x.c] = 0; for (auto x: g[k.se]) { ma[x.c] += x.p; min_c[x.c] = min(min_c[x.c], d[x.v]); } for (auto x: g[k.se]) { if (d[x.v] > k.fi + x.p) { d[x.v] = k.fi + x.p; q.push({d[x.v], x.v}); } if (d[x.v] > k.fi + ma[x.c] - x.p) { d[x.v] = d[k.fi] + ma[x.c] - x.p; q.push({d[x.v], x.v}); } if (d[x.v] > min_c[x.c] + ma[x.c] - x.p) { d[x.v] = min_c[x.c] + ma[x.c] - x.p; q.push({d[x.v], x.v}); } } } if (d[n] >= oo) d[n] = -1; } int main() { ios::sync_with_stdio(0); cin.tie(0); #define TASK "" if (fopen (".inp", "r")) { freopen (".inp", "r", stdin); freopen (".out", "w", stdout); } if(fopen(TASK".inp", "r")) { freopen(TASK".inp", "r", stdin); freopen(TASK".out", "w", stdout); } cin >> n >> m; For (i, 1, m) { int u, v, c, p; cin >> u >> v >> c >> p; g[u].push_back({v, c, p}); g[v].push_back({u, c, p}); } dij(); cout << d[n] << '\n'; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int main()':
Main.cpp:64:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   64 |         freopen (".inp", "r", stdin);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~
Main.cpp:65:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   65 |         freopen (".out", "w", stdout);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
Main.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(TASK".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:69:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   69 |         freopen(TASK".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...