답안 #833898

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
833898 2023-08-22T09:24:29 Z BilAktauAlmansur 관광지 (IZhO14_shymbulak) C++17
50 / 100
1500 ms 10316 KB
#include <bits/stdc++.h>
#pragma optimize ("g",on)
#pragma GCC optimize ("inline")
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("03")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,avx2,mmx,fma,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
// #define int long long
using namespace std;
const int N = 2e5 + 7;
vector<vector<int> > g(N);

signed main() {
    // freopen("bank.in", "r", stdin); 
    // freopen("bank.out", "w", stdout);
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    int n;
    cin>>n;
    for(int i = 1; i <= n; i++) {
        int x, y;
        cin>>x>>y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    int cnt = 0, ans = 0;
    for(int i = 1; i <= n; i++) {
        queue<int> q;
        q.push(i);
        vector<int> us(n + 1, 0), d(n + 1, 0), cn(n + 1, 1);
        us[i] = 1;
        while(!q.empty()) {
            int v = q.front();
            q.pop();
            for(auto to : g[v]) {
                if(!us[to]) {
                    us[to] = 1;
                    d[to] = d[v] + 1, cn[to] = cn[v];
                    q.push(to);
                }else {
                    if(d[to] == d[v] + 1)cn[to] ++;
                }
            }
        }
        for(int j = 1; j <= n; j++) {
            if(d[j] > cnt) {
                cnt = d[j], ans = cn[j];
            }else if(d[j] == cnt)ans += cn[j];
        }
    }
    cout << ans / 2 << '\n';
}

Compilation message

shymbulak.cpp:2: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
    2 | #pragma optimize ("g",on)
      | 
shymbulak.cpp:8: warning: ignoring '#pragma comment ' [-Wunknown-pragmas]
    8 | #pragma comment(linker, "/stack:200000000")
      |
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4968 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 3 ms 4996 KB Output is correct
6 Correct 2 ms 4948 KB Output is correct
7 Correct 4 ms 4948 KB Output is correct
8 Correct 3 ms 4948 KB Output is correct
9 Correct 3 ms 4960 KB Output is correct
10 Correct 3 ms 4948 KB Output is correct
11 Correct 2 ms 4948 KB Output is correct
12 Correct 2 ms 4948 KB Output is correct
13 Correct 2 ms 4948 KB Output is correct
14 Correct 5 ms 4948 KB Output is correct
15 Correct 8 ms 4948 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 4948 KB Output is correct
2 Correct 7 ms 5124 KB Output is correct
3 Correct 14 ms 4948 KB Output is correct
4 Correct 13 ms 5076 KB Output is correct
5 Correct 251 ms 5276 KB Output is correct
6 Correct 201 ms 5332 KB Output is correct
7 Correct 310 ms 5204 KB Output is correct
8 Correct 314 ms 5296 KB Output is correct
9 Correct 255 ms 5300 KB Output is correct
10 Correct 288 ms 5204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1537 ms 10316 KB Time limit exceeded
2 Halted 0 ms 0 KB -