Submission #1105415

#TimeUsernameProblemLanguageResultExecution timeMemory
1105415minhvuleHotspot (NOI17_hotspot)C++17
38 / 100
108 ms864 KiB
#include <bits/stdc++.h> #define int long long #define pb push_back #define freo(task) if(fopen(task".inp", "r")){ freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } #define FOR(i, a, b) for(int i=(a),_b = (b); i<=_b; i++) #define FORD(i, a, b) for(int i=(a),_b = (b); i>=_b; i--) #define bit(x, i) ((x >> i) & 1) #define oo 1e18 #define pii pair<int, int> #define debug cout<<"VUDEPTRAI\n"; using namespace std; // mt19937 rd(chrono::steady_clock::now().time_since_epoch().count()); // ll rand(ll l, ll r) { assert(l <= r); return uniform_int_distribution<ll>(l, r)(rd); } const int N = 5e3 + 5; int n, m, k, pa[N], pb[N], da[N], db[N]; vector<int> g[N]; double sum[N]; void dijkstra(int u, int d[], int pa[]){ priority_queue<pii> pq; d[u] = 0; pq.push({0, u}); while(!pq.empty()){ pii top = pq.top(); pq.pop(); int u = top.second; if(top.first > d[u]) continue; for(int v:g[u]) if(d[v] > d[u] + 1){ d[v] = d[u] + 1; pa[v] = pa[u]; pq.push({d[v], v}); } else if(d[v] == d[u] + 1) pa[v] += pa[u]; } } void sub6(){ FOR(i, 1, m){ int u, v; cin>>u>>v; g[u].pb(v); g[v].pb(u); } cin>>k; FOR(i, 1, k){ int a, b; cin>>a>>b; FOR(i, 0, n) da[i] = db[i] = INT_MAX, pa[i] = pb[i] = 1; dijkstra(a, da, pa); dijkstra(b, db, pb); // cout<<pa[b]<<" "; FOR(u, 0, n) if(da[u] + db[u] == da[b]) sum[u] += (pa[u] * pb[u] * 1.0) / pa[b] * 1.0; } int ans = 0; FOR(i, 1, n) if(sum[i] > sum[ans]) ans = i; cout<<ans; } void solve(){ cin>>n>>m; sub6(); } int32_t main(){ ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); freo("TRAINCENTRE"); solve(); // cerr << "\nTime: " << 1.0 * clock() / CLOCKS_PER_SEC << "s\n"; return 0; } /* */

Compilation message (stderr)

hotspot.cpp: In function 'int32_t main()':
hotspot.cpp:4:55: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    4 | #define freo(task) if(fopen(task".inp", "r")){ freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); }
      |                                                ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
hotspot.cpp:64:5: note: in expansion of macro 'freo'
   64 |     freo("TRAINCENTRE");
      |     ^~~~
hotspot.cpp:4:88: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    4 | #define freo(task) if(fopen(task".inp", "r")){ freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); }
      |                                                                                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
hotspot.cpp:64:5: note: in expansion of macro 'freo'
   64 |     freo("TRAINCENTRE");
      |     ^~~~
#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...