제출 #852902

#제출 시각아이디문제언어결과실행 시간메모리
852902Anonymous_GuysCommuter Pass (JOI18_commuter_pass)C++17
0 / 100
101 ms16068 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define ii pair<int, int> #define ll long long #define int long long #define fi first #define se second #define fou(i, a, b) for (int i = a; i <= b; ++i) #define all(v) (v).begin(), (v).end() #define el '\n' #define MASK(x) (1LL << (x)) #define BIT(mask, x) (((mask) >> (i)) & 1) const int mxN = 1e5 + 9; const int MOD =(int)1e9 + 7; const int INF =(int)1e9; int d[mxN]; vector<ii> adj[mxN]; void dijsktra(int s) { memset(d, 0x3f, sizeof d); d[s] = 0; priority_queue<ii, vector<ii>, greater<ii> > q; q.push({0, s}); while(!q.empty()) { int u = q.top().se; int kc = q.top().fi; q.pop(); if (d[u] != kc) continue; for (auto it : adj[u]) { int v = it.fi; int w = it.se; if (d[v] > d[u] + w) { d[v] = d[u] + w; q.push({d[v], v}); } } } } signed main() { if (fopen("GIAOPIZZA.INP", "r")) { freopen("GIAOPIZZA.INP", "r", stdin); freopen("GIAOPIZZA.OUT", "w", stdout); } ios_base::sync_with_stdio(false); cin.tie(0); int n,m ; cin >> n >> m; int tram_S, tram_T; cin >> tram_S >> tram_T; int tram_U, tram_V; cin >> tram_U >> tram_V; fou(i, 1, m) { int u, v, w; cin >> u >> v >> w; adj[u].pb({v, w}); adj[v].pb({u, w}); } dijsktra(tram_U); cout << d[tram_V]; return 0; }

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

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