답안 #17963

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
17963 2016-01-13T09:57:48 Z Adilkhan 관광지 (IZhO14_shymbulak) C++
50 / 100
706 ms 205288 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 = 5020;
const ll INF = (ll)(1e9);
const ll mod = (ll)(1e9) + 7;
const double eps = 1e-9;

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

queue <int> q;

void fmbfs(int 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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 198720 KB Output is correct
2 Correct 0 ms 198720 KB Output is correct
3 Correct 0 ms 198720 KB Output is correct
4 Correct 0 ms 198720 KB Output is correct
5 Correct 0 ms 198720 KB Output is correct
6 Correct 0 ms 198720 KB Output is correct
7 Correct 0 ms 198720 KB Output is correct
8 Correct 0 ms 198720 KB Output is correct
9 Correct 0 ms 198720 KB Output is correct
10 Correct 0 ms 198720 KB Output is correct
11 Correct 0 ms 198720 KB Output is correct
12 Correct 0 ms 198720 KB Output is correct
13 Correct 0 ms 198720 KB Output is correct
14 Correct 4 ms 198720 KB Output is correct
15 Correct 4 ms 198720 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 198720 KB Output is correct
2 Correct 14 ms 198720 KB Output is correct
3 Correct 27 ms 198720 KB Output is correct
4 Correct 22 ms 198720 KB Output is correct
5 Correct 628 ms 198852 KB Output is correct
6 Correct 403 ms 198852 KB Output is correct
7 Correct 667 ms 198852 KB Output is correct
8 Correct 706 ms 198852 KB Output is correct
9 Correct 605 ms 198852 KB Output is correct
10 Correct 664 ms 198852 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 13 ms 199376 KB SIGSEGV Segmentation fault
2 Runtime error 0 ms 199244 KB SIGSEGV Segmentation fault
3 Runtime error 0 ms 198848 KB SIGSEGV Segmentation fault
4 Runtime error 0 ms 198848 KB SIGSEGV Segmentation fault
5 Runtime error 2 ms 198848 KB SIGSEGV Segmentation fault
6 Runtime error 15 ms 200432 KB SIGSEGV Segmentation fault
7 Runtime error 43 ms 202676 KB SIGSEGV Segmentation fault
8 Runtime error 2 ms 198848 KB SIGSEGV Segmentation fault
9 Runtime error 0 ms 198848 KB SIGSEGV Segmentation fault
10 Runtime error 0 ms 198848 KB SIGSEGV Segmentation fault
11 Runtime error 0 ms 205288 KB SIGSEGV Segmentation fault
12 Runtime error 22 ms 200956 KB SIGSEGV Segmentation fault