Submission #17961

# Submission time Handle Problem Language Result Execution time Memory
17961 2016-01-13T09:56:16 Z Adilkhan Shymbulak (IZhO14_shymbulak) C++
0 / 100
0 ms 262144 KB
#include <bits/stdc++.h>

#define pb push_back
#define endl "\n"
#define mp make_pair 
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define fname ""
#define sz(x) (int)(x.size())

typedef long long ll;

using namespace std;

const ll N = 5322;
const ll INF = (ll)(1e9);
const ll mod = (ll)(1e9) + 7;
const double eps = 1e-9;

ll d[N][N][2], n, m, mx, sum;
        
vector <ll> v[N];

queue <ll> q;

void fmbfs(ll s) {               
	for (int i = 1; i <= n; ++i) d[s][i][1] = 0, d[s][i][0] = -1;
	q.push(s);
	d[s][s][0] = 0; d[s][s][1] = 1;
	while (!q.empty()) {
		int x = q.front();
		q.pop();
		for (int j = 0; j < sz(v[x]); ++j) {
			int to = v[x][j];
			if (d[s][to][0] == -1) {
				d[s][to][0] = d[s][x][0] + 1;
				d[s][to][1] += d[s][x][1];
				q.push(to);			
				continue;
			}		
			if (d[s][to][0] == d[s][x][0] + 1) {
				d[s][to][1] += d[s][x][1];
			}
		}	
	}	
	for (int i = 1; i <= n; ++i) {
		mx = max(mx, d[s][i][0]);
	}         
}

int main () {
	//freopen(fname".in", "r", stdin);
	//freopen(fname".out", "w", stdout);
	scanf("%lld", &n);
	for (int i = 1; i <= n; ++i) {
		ll x, y; scanf("%lld%lld", &x, &y);
		v[x].pb(y); v[y].pb(x);
	}
	for (int i = 1; i <= n; ++i) {
		fmbfs(i);
	}
	for (int i = 1; i <= n; ++i) {
		for (int j = i + 1; j <= n; ++j) {
			if (d[i][j][0] == mx) {
				sum += d[i][j][1];			
			}		
		}
	}
	printf("%lld", sum);   
	return 0;
}
# Verdict Execution time Memory Grader output
1 Memory limit exceeded 0 ms 262144 KB Memory limit exceeded
2 Memory limit exceeded 0 ms 262144 KB Memory limit exceeded
3 Memory limit exceeded 0 ms 262144 KB Memory limit exceeded
4 Memory limit exceeded 0 ms 262144 KB Memory limit exceeded
5 Memory limit exceeded 0 ms 262144 KB Memory limit exceeded
6 Memory limit exceeded 0 ms 262144 KB Memory limit exceeded
7 Memory limit exceeded 0 ms 262144 KB Memory limit exceeded
8 Memory limit exceeded 0 ms 262144 KB Memory limit exceeded
9 Memory limit exceeded 0 ms 262144 KB Memory limit exceeded
10 Memory limit exceeded 0 ms 262144 KB Memory limit exceeded
11 Memory limit exceeded 0 ms 262144 KB Memory limit exceeded
12 Memory limit exceeded 0 ms 262144 KB Memory limit exceeded
13 Memory limit exceeded 0 ms 262144 KB Memory limit exceeded
14 Memory limit exceeded 0 ms 262144 KB Memory limit exceeded
15 Memory limit exceeded 0 ms 262144 KB Memory limit exceeded
# Verdict Execution time Memory Grader output
1 Memory limit exceeded 0 ms 262144 KB Memory limit exceeded
2 Memory limit exceeded 0 ms 262144 KB Memory limit exceeded
3 Memory limit exceeded 0 ms 262144 KB Memory limit exceeded
4 Memory limit exceeded 0 ms 262144 KB Memory limit exceeded
5 Memory limit exceeded 0 ms 262144 KB Memory limit exceeded
6 Memory limit exceeded 0 ms 262144 KB Memory limit exceeded
7 Memory limit exceeded 0 ms 262144 KB Memory limit exceeded
8 Memory limit exceeded 0 ms 262144 KB Memory limit exceeded
9 Memory limit exceeded 0 ms 262144 KB Memory limit exceeded
10 Memory limit exceeded 0 ms 262144 KB Memory limit exceeded
# Verdict Execution time Memory Grader output
1 Memory limit exceeded 0 ms 262144 KB Memory limit exceeded
2 Memory limit exceeded 0 ms 262144 KB Memory limit exceeded
3 Memory limit exceeded 0 ms 262144 KB Memory limit exceeded
4 Memory limit exceeded 0 ms 262144 KB Memory limit exceeded
5 Memory limit exceeded 0 ms 262144 KB Memory limit exceeded
6 Memory limit exceeded 0 ms 262144 KB Memory limit exceeded
7 Memory limit exceeded 0 ms 262144 KB Memory limit exceeded
8 Memory limit exceeded 0 ms 262144 KB Memory limit exceeded
9 Memory limit exceeded 0 ms 262144 KB Memory limit exceeded
10 Memory limit exceeded 0 ms 262144 KB Memory limit exceeded
11 Memory limit exceeded 0 ms 262144 KB Memory limit exceeded
12 Memory limit exceeded 0 ms 262144 KB Memory limit exceeded