제출 #839678

#제출 시각아이디문제언어결과실행 시간메모리
839678thegamercoder19Commuter Pass (JOI18_commuter_pass)C++14
15 / 100
187 ms26684 KiB
/* Coded by thegamercoder19 GL */ #define _CRT_SECURE_NO_WARNINGS #include <bits/stdc++.h> #define M_PI 3.14159265358979323846 #define FILER 0 using ll = long long; using ull = unsigned long long; using ld = long double; const ll MOD = pow(10, 9) + 7; const ll INFL = 0x3f3f3f3f3f3f3f3f; const ull INFUL = 0x3f3f3f3f3f3f3f3f; const ll INFT = 0x3f3f3f3f; const ll MAX = 1e5+1; const ll MAXX = 31; const ll MODD = 998244353; const double EPS = 1e-10; const ll B = 350; #define V vector #define pll pair<ll, ll> #define pull2 pair<ull,ull> #define MS multiset #define Q queue #define PQ priority_queue #define IOF ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define FOR(typ,i,a,b,c) for(typ i = a; i < b; i += c) #define FORR(typ,i,a,b,c) for(typ i = a; i > b; i -= c) #define FORA(a,i) for(auto &i : a) #define all(v) begin(v), end(v) #define sz(v) v.size() #define sorta(a) sort(all(a)) #define sortd(a) sort(all(a), greater<ll>()) #define setp(x) setprecision(x)<<fixed #define RET return #define log(a,b) log(b)/log(a) #define WH(s) while(s) #define WHI(t) WH(t--) #define YES cout<<"YES"<<endl; #define NO cout<<"NO"<<endl; #define Yes cout<<"Yes"<<endl; #define No cout<<"No"<<endl; #define YESNO(s) cout << (s ? "YES" : "NO") << endl; #define YesNo(s) cout<<(s?"Yes":"No")<<endl; #define TYP 0 //#define endl '\n' using namespace std; struct edge { ll u, v, k; }; ll n, m, s, t, u, v,x,y,k; V<V<pll>> g; V<edge> ge; ll dijkstra(ll b, ll e) { ll e1 = e; V<ll> d(n + 1, INFL), p(n + 1, -1), dp(n + 1, INFL); PQ<pll, V<pll>, greater<pll>> pq; pq.push({ 0,b }); d[b] = 0; WH(!pq.empty()) { ll u = pq.top().second, du = pq.top().first; pq.pop(); if (du != d[u])continue; FORA(g[u], v) { if (d[v.first] > du + v.second) { d[v.first] = du + v.second; pq.push({ d[v.first], v.first }); p[v.first] = u; //dp[v.first]=dp[u]; } if (d[v.first] == du + v.second) { dp[v.first] += dp[u]; } } } WH(p[e] != -1) { g[e].push_back({ p[e],0 }); g[p[e]].push_back({ e,0 }); e = p[e]; } RET d[e1]; } void solve() { cin >> n >> m >> s >> t >> u >> v; g.resize(n + 1); FOR(ll, i, 0, m, 1) cin >> x >> y >> k, g[x].push_back({ y,k }), g[y].push_back({ x,k }); auto ans1 = dijkstra(s, t); cout << dijkstra(u, v) << endl; } void init() { if (FILER) { freopen("grassplant.in", "r", stdin); freopen("grassplant.out", "w", stdout); } } void handle() { init(); ll t = 1; if (TYP)cin >> t; //getline(cin, s); WHI(t)solve(); } int main() { IOF handle(); RET 0; }

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

commuter_pass.cpp: In function 'void solve()':
commuter_pass.cpp:99:10: warning: unused variable 'ans1' [-Wunused-variable]
   99 |     auto ans1 = dijkstra(s, t);
      |          ^~~~
commuter_pass.cpp: In function 'void init()':
commuter_pass.cpp:107:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  107 |         freopen("grassplant.in", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
commuter_pass.cpp:108:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  108 |         freopen("grassplant.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...