Submission #1105451

# Submission time Handle Problem Language Result Execution time Memory
1105451 2024-10-26T12:45:59 Z hainam2k9 Hotspot (NOI17_hotspot) C++17
0 / 100
43 ms 196520 KB
#include <bits/stdc++.h>
#define tt cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(0)
#define fo freopen((NAME+".INP").c_str(), "r", stdin), freopen((NAME+".OUT").c_str(), "w", stdout)
#define ll long long
#define ull unsigned long long
#define i128 __int128
#define db long double
#define sz(a) ((int)(a).size())
#define pb emplace_back
#define pf emplace_front
#define pob pop_back
#define pof pop_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define ins emplace
using namespace std;
const int MOD = 1e9+7, MAXN = 1e5+5;
const string NAME = "TRAINCENTRE";
int n,m,k,x,y;
vector<int> adj[5005];
pair<int,int> dist[5005][5005],p[2005];
pair<int,db> rs;
int main()
{
    tt;
    if(fopen((NAME + ".INP").c_str(), "r")) fo;
    cin >> n >> m;
    for(int i = 1; i<=m; ++i)
        cin >> x >> y, ++x, ++y, adj[x].pb(y), adj[y].pb(x);
    memset(dist,0x3f,sizeof(dist));
    for(int i = 1; i<=n; ++i){
        queue<int> q;
        q.push(i), dist[i][i].fi=0, dist[i][i].se=1;
        while(!q.empty()){
            int u = q.front();
            for(int v : adj[u]){
                if(dist[i][v].fi>dist[i][u].fi+1) dist[i][v].fi=dist[i][u].fi+1, dist[i][v].se=dist[i][u].se, q.push(v);
                else if(dist[i][v].fi==dist[i][u].fi+1) dist[i][v].se+=dist[i][u].se;
            }
            q.pop();
        }
    }
    cin >> k;
    for(int i = 1; i<=k; ++i)
        cin >> p[i].fi >> p[i].se, ++p[i].fi, ++p[i].se;
    for(int i = 1; i<=n; ++i){
        db e=0;
        for(int j = 1; j<=k; ++j){
            if(dist[i][p[j].fi].fi+dist[i][p[j].se].fi>dist[p[j].fi][p[j].se].fi) continue;
            e+=1.0L*dist[p[j].fi][i].se*dist[p[j].se][i].se/dist[p[i].fi][p[i].se].se;
        }
        if(e>rs.se) rs.fi=i, rs.se=e;
    }
    cout << rs.fi+1;
}

Compilation message

hotspot.cpp: In function 'int main()':
hotspot.cpp:3:19: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    3 | #define fo freopen((NAME+".INP").c_str(), "r", stdin), freopen((NAME+".OUT").c_str(), "w", stdout)
      |            ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
hotspot.cpp:28:45: note: in expansion of macro 'fo'
   28 |     if(fopen((NAME + ".INP").c_str(), "r")) fo;
      |                                             ^~
hotspot.cpp:3:63: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    3 | #define fo freopen((NAME+".INP").c_str(), "r", stdin), freopen((NAME+".OUT").c_str(), "w", stdout)
      |                                                        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
hotspot.cpp:28:45: note: in expansion of macro 'fo'
   28 |     if(fopen((NAME + ".INP").c_str(), "r")) fo;
      |                                             ^~
# Verdict Execution time Memory Grader output
1 Incorrect 43 ms 196520 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 43 ms 196520 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 43 ms 196520 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 43 ms 196520 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 43 ms 196520 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 43 ms 196520 KB Output isn't correct
2 Halted 0 ms 0 KB -