Submission #37876

# Submission time Handle Problem Language Result Execution time Memory
37876 2017-12-28T13:57:36 Z Just_Solve_The_Problem Shymbulak (IZhO14_shymbulak) C++11
0 / 100
1500 ms 8176 KB
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define fr first
#define sc second

const int N = (int)1e5 + 7;

vector < int > gr[N];
int used[N];
int ans[N];
pair < int, int > otv;

void dfs (int v, int h = 0) {
    used[v] = h;
    ans[v] = 1;
    for (int to : gr[v]) {
        if (h + 1 < used[to]) {
            dfs(to, h + 1);
        } else if (h + 1 == used[to]) {
            ans[to]++;
        }
    }
}

main () {
    int n; scanf ("%d", &n);
    for (int i = 1; i <= n; i++) {
        int u, v; scanf ("%d %d", &u, &v);
        gr[u].pb(v);
        gr[v].pb(u);
    }
    pair < int, int > res;
    res = {0, 0};
    for (int i = 1; i <= n; i++) {
        memset(used, 63, sizeof(used));
        dfs(i);
        for (int j = 1; j <= n; j++) {
            if (used[j] > res.fr) {
                res.fr = used[j];
                res.sc = ans[j];
            } else if (used[j] == res.fr) {
                res.sc += ans[j];
            }
        }
    }
    cout << res.sc - 2;
}

Compilation message

shymbulak.cpp:28:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main () {
       ^
shymbulak.cpp: In function 'int main()':
shymbulak.cpp:29:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     int n; scanf ("%d", &n);
                            ^
shymbulak.cpp:31:42: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         int u, v; scanf ("%d %d", &u, &v);
                                          ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 5140 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 33 ms 5140 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1500 ms 8176 KB Execution timed out
2 Halted 0 ms 0 KB -