답안 #1105345

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1105345 2024-10-26T08:18:24 Z minhvule Hotspot (NOI17_hotspot) C++17
38 / 100
60 ms 608 KB
#include <bits/stdc++.h>
#define ll 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, cnt[N], from[N];
vector<int> g[N];
void dijkstra(int u, int v){
    vector<int> d(N, INT_MAX);
    priority_queue<pii> pq;
    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;
                from[v] = u;
                pq.push({d[v], v});
            }
    }
    while(v != u){
        cnt[v] ++;
        v = from[v];
    }
    cnt[u] ++;
}
void solve(){
    cin>>n>>m;
    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;
        dijkstra(a, b);
    }
    int ans = -1, tmp = INT_MIN;
    FOR(i, 1, n)
        if(cnt[i] > tmp){
            tmp = cnt[i];
            ans = i;
        }
    cout<<ans;
}
int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    // freo("");
    solve();
    // cerr << "\nTime: " << 1.0 * clock() / CLOCKS_PER_SEC << "s\n";
    return 0;
}
/*
 


*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 592 KB Output is correct
2 Correct 1 ms 592 KB Output is correct
3 Correct 1 ms 592 KB Output is correct
4 Correct 1 ms 592 KB Output is correct
5 Correct 1 ms 592 KB Output is correct
6 Correct 1 ms 592 KB Output is correct
7 Correct 1 ms 592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 592 KB Output is correct
2 Correct 1 ms 592 KB Output is correct
3 Correct 1 ms 592 KB Output is correct
4 Correct 1 ms 592 KB Output is correct
5 Correct 1 ms 592 KB Output is correct
6 Correct 1 ms 592 KB Output is correct
7 Correct 1 ms 592 KB Output is correct
8 Correct 1 ms 592 KB Output is correct
9 Correct 1 ms 592 KB Output is correct
10 Correct 1 ms 592 KB Output is correct
11 Correct 1 ms 592 KB Output is correct
12 Correct 1 ms 592 KB Output is correct
13 Correct 1 ms 592 KB Output is correct
14 Correct 1 ms 592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 592 KB Output is correct
2 Correct 1 ms 592 KB Output is correct
3 Correct 1 ms 592 KB Output is correct
4 Correct 1 ms 592 KB Output is correct
5 Correct 1 ms 592 KB Output is correct
6 Correct 1 ms 592 KB Output is correct
7 Correct 1 ms 592 KB Output is correct
8 Correct 1 ms 608 KB Output is correct
9 Correct 1 ms 592 KB Output is correct
10 Correct 1 ms 592 KB Output is correct
11 Correct 2 ms 592 KB Output is correct
12 Correct 2 ms 592 KB Output is correct
13 Correct 1 ms 592 KB Output is correct
14 Correct 2 ms 592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 592 KB Output is correct
2 Correct 1 ms 592 KB Output is correct
3 Correct 1 ms 592 KB Output is correct
4 Correct 1 ms 592 KB Output is correct
5 Correct 1 ms 592 KB Output is correct
6 Correct 1 ms 592 KB Output is correct
7 Correct 1 ms 592 KB Output is correct
8 Correct 1 ms 592 KB Output is correct
9 Correct 1 ms 592 KB Output is correct
10 Correct 1 ms 592 KB Output is correct
11 Correct 1 ms 592 KB Output is correct
12 Correct 1 ms 592 KB Output is correct
13 Correct 1 ms 592 KB Output is correct
14 Correct 1 ms 592 KB Output is correct
15 Correct 1 ms 608 KB Output is correct
16 Correct 1 ms 592 KB Output is correct
17 Correct 1 ms 592 KB Output is correct
18 Correct 2 ms 592 KB Output is correct
19 Correct 2 ms 592 KB Output is correct
20 Correct 1 ms 592 KB Output is correct
21 Correct 2 ms 592 KB Output is correct
22 Correct 2 ms 592 KB Output is correct
23 Correct 2 ms 592 KB Output is correct
24 Correct 3 ms 592 KB Output is correct
25 Correct 5 ms 592 KB Output is correct
26 Correct 4 ms 592 KB Output is correct
27 Correct 1 ms 592 KB Output is correct
28 Correct 3 ms 592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 592 KB Output is correct
2 Correct 1 ms 592 KB Output is correct
3 Correct 1 ms 592 KB Output is correct
4 Correct 1 ms 592 KB Output is correct
5 Correct 1 ms 592 KB Output is correct
6 Correct 1 ms 592 KB Output is correct
7 Correct 1 ms 592 KB Output is correct
8 Correct 1 ms 592 KB Output is correct
9 Correct 1 ms 592 KB Output is correct
10 Correct 1 ms 592 KB Output is correct
11 Correct 1 ms 592 KB Output is correct
12 Correct 1 ms 592 KB Output is correct
13 Correct 1 ms 592 KB Output is correct
14 Correct 1 ms 592 KB Output is correct
15 Correct 1 ms 592 KB Output is correct
16 Correct 2 ms 592 KB Output is correct
17 Correct 36 ms 592 KB Output is correct
18 Correct 37 ms 592 KB Output is correct
19 Correct 60 ms 592 KB Output is correct
20 Correct 2 ms 592 KB Output is correct
21 Incorrect 1 ms 592 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 592 KB Output is correct
2 Correct 1 ms 592 KB Output is correct
3 Correct 1 ms 592 KB Output is correct
4 Correct 1 ms 592 KB Output is correct
5 Correct 1 ms 592 KB Output is correct
6 Correct 1 ms 592 KB Output is correct
7 Correct 1 ms 592 KB Output is correct
8 Correct 1 ms 592 KB Output is correct
9 Correct 1 ms 592 KB Output is correct
10 Correct 1 ms 592 KB Output is correct
11 Correct 1 ms 592 KB Output is correct
12 Correct 1 ms 592 KB Output is correct
13 Correct 1 ms 592 KB Output is correct
14 Correct 1 ms 592 KB Output is correct
15 Correct 1 ms 608 KB Output is correct
16 Correct 1 ms 592 KB Output is correct
17 Correct 1 ms 592 KB Output is correct
18 Correct 2 ms 592 KB Output is correct
19 Correct 2 ms 592 KB Output is correct
20 Correct 1 ms 592 KB Output is correct
21 Correct 2 ms 592 KB Output is correct
22 Correct 2 ms 592 KB Output is correct
23 Correct 2 ms 592 KB Output is correct
24 Correct 3 ms 592 KB Output is correct
25 Correct 5 ms 592 KB Output is correct
26 Correct 4 ms 592 KB Output is correct
27 Correct 1 ms 592 KB Output is correct
28 Correct 3 ms 592 KB Output is correct
29 Correct 1 ms 592 KB Output is correct
30 Correct 2 ms 592 KB Output is correct
31 Correct 36 ms 592 KB Output is correct
32 Correct 37 ms 592 KB Output is correct
33 Correct 60 ms 592 KB Output is correct
34 Correct 2 ms 592 KB Output is correct
35 Incorrect 1 ms 592 KB Output isn't correct
36 Halted 0 ms 0 KB -