답안 #680854

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
680854 2023-01-11T22:45:06 Z alwaystle Hotspot (NOI17_hotspot) C++17
100 / 100
1649 ms 216096 KB
// Everything will be just tickety-boo!

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

#define forr(_a, _b, _c) for(_a = (_b); _a <= (_c); ++_a)
#define ford(_a, _b, _c) for(_a = (_b) + 1; _a --> (_c);)
#define forf(_a, _b, _c) for(_a = (_b); _a < (_c); ++_a)
#define mp make_pair
#define fi first
#define se second
#define vi vector
#define sz(_v) _v.begin(), _v.end()
#define mask(_x) (1ll << (_x))
#define bit(_x,_y) (((_x) >> (_y)) & 1)

const int N = 5e3 + 5;
int n, i, m, k, x, y, d[N][N], j, a[N], b[N];
vi<int> adj[N];
deque<int> st;
ll f[N][N];
bool dd[N];
pair<ld,int> o[N];
ld t1, t2;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	#ifdef umf
		freopen("test.inp","r",stdin);
		freopen("test.out","w",stdout);
	#endif

	cin >> n >> m;
	while(m--) {
		cin >> x >> y;
		++x;
		++y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	forr(i,1,n) {
		memset(dd,false,sizeof(dd));
		f[i][i] = 1;
		st.push_back(i);
		dd[i] = true;
		while(st.size()) {
			x = st.front();
			st.pop_front();
			forf(j,0,adj[x].size()) {
				y = adj[x][j];
				if(!dd[y]) {
					dd[y] = true;
					st.push_back(y);
					d[i][y] = d[i][x] + 1;
				}
				if(d[i][x] + 1 == d[i][y]) f[i][y] += f[i][x];
			}
		}
	}
	cin >> k;
	forr(i,1,k) {
		cin >> a[i] >> b[i];
		++a[i];
		++b[i];
	}
	forr(i,1,n) {
		o[i].se = i;
		forr(j,1,k) {
			if(d[a[j]][i] + d[i][b[j]] == d[a[j]][b[j]]) {
				t1 = f[a[j]][i] * f[i][b[j]];
				t2 = f[a[j]][b[j]];
				o[i].fi += t1 / t2;
			}
		}
	}
	sort(o + 1,o + 1 + n);
	cout << o[n].se - 1;

	return 0;
}

Compilation message

hotspot.cpp: In function 'int main()':
hotspot.cpp:10:44: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 | #define forf(_a, _b, _c) for(_a = (_b); _a < (_c); ++_a)
      |                                            ^
hotspot.cpp:51:4: note: in expansion of macro 'forf'
   51 |    forf(j,0,adj[x].size()) {
      |    ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 7764 KB Output is correct
2 Correct 20 ms 14676 KB Output is correct
3 Correct 16 ms 12880 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 4 ms 4104 KB Output is correct
6 Correct 3 ms 3028 KB Output is correct
7 Correct 9 ms 8028 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 7764 KB Output is correct
2 Correct 20 ms 14676 KB Output is correct
3 Correct 16 ms 12880 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 4 ms 4104 KB Output is correct
6 Correct 3 ms 3028 KB Output is correct
7 Correct 9 ms 8028 KB Output is correct
8 Correct 4 ms 3156 KB Output is correct
9 Correct 12 ms 8148 KB Output is correct
10 Correct 25 ms 15008 KB Output is correct
11 Correct 1 ms 1364 KB Output is correct
12 Correct 1 ms 724 KB Output is correct
13 Correct 5 ms 4292 KB Output is correct
14 Correct 13 ms 9704 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 7764 KB Output is correct
2 Correct 20 ms 14676 KB Output is correct
3 Correct 16 ms 12880 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 4 ms 4104 KB Output is correct
6 Correct 3 ms 3028 KB Output is correct
7 Correct 9 ms 8028 KB Output is correct
8 Correct 4 ms 4436 KB Output is correct
9 Correct 12 ms 9928 KB Output is correct
10 Correct 11 ms 8524 KB Output is correct
11 Correct 23 ms 15480 KB Output is correct
12 Correct 1 ms 1620 KB Output is correct
13 Correct 1 ms 852 KB Output is correct
14 Correct 5 ms 4564 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 7764 KB Output is correct
2 Correct 20 ms 14676 KB Output is correct
3 Correct 16 ms 12880 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 4 ms 4104 KB Output is correct
6 Correct 3 ms 3028 KB Output is correct
7 Correct 9 ms 8028 KB Output is correct
8 Correct 4 ms 3156 KB Output is correct
9 Correct 12 ms 8148 KB Output is correct
10 Correct 25 ms 15008 KB Output is correct
11 Correct 1 ms 1364 KB Output is correct
12 Correct 1 ms 724 KB Output is correct
13 Correct 5 ms 4292 KB Output is correct
14 Correct 13 ms 9704 KB Output is correct
15 Correct 4 ms 4436 KB Output is correct
16 Correct 12 ms 9928 KB Output is correct
17 Correct 11 ms 8524 KB Output is correct
18 Correct 23 ms 15480 KB Output is correct
19 Correct 1 ms 1620 KB Output is correct
20 Correct 1 ms 852 KB Output is correct
21 Correct 5 ms 4564 KB Output is correct
22 Correct 7 ms 5832 KB Output is correct
23 Correct 5 ms 4692 KB Output is correct
24 Correct 15 ms 10324 KB Output is correct
25 Correct 28 ms 17772 KB Output is correct
26 Correct 28 ms 15908 KB Output is correct
27 Correct 2 ms 1748 KB Output is correct
28 Correct 8 ms 5972 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 7764 KB Output is correct
2 Correct 20 ms 14676 KB Output is correct
3 Correct 16 ms 12880 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 4 ms 4104 KB Output is correct
6 Correct 3 ms 3028 KB Output is correct
7 Correct 9 ms 8028 KB Output is correct
8 Correct 4 ms 3156 KB Output is correct
9 Correct 12 ms 8148 KB Output is correct
10 Correct 25 ms 15008 KB Output is correct
11 Correct 1 ms 1364 KB Output is correct
12 Correct 1 ms 724 KB Output is correct
13 Correct 5 ms 4292 KB Output is correct
14 Correct 13 ms 9704 KB Output is correct
15 Correct 15 ms 1964 KB Output is correct
16 Correct 20 ms 6096 KB Output is correct
17 Correct 75 ms 12452 KB Output is correct
18 Correct 33 ms 10720 KB Output is correct
19 Correct 88 ms 18332 KB Output is correct
20 Correct 14 ms 2900 KB Output is correct
21 Correct 4 ms 1996 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 7764 KB Output is correct
2 Correct 20 ms 14676 KB Output is correct
3 Correct 16 ms 12880 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 4 ms 4104 KB Output is correct
6 Correct 3 ms 3028 KB Output is correct
7 Correct 9 ms 8028 KB Output is correct
8 Correct 4 ms 3156 KB Output is correct
9 Correct 12 ms 8148 KB Output is correct
10 Correct 25 ms 15008 KB Output is correct
11 Correct 1 ms 1364 KB Output is correct
12 Correct 1 ms 724 KB Output is correct
13 Correct 5 ms 4292 KB Output is correct
14 Correct 13 ms 9704 KB Output is correct
15 Correct 4 ms 4436 KB Output is correct
16 Correct 12 ms 9928 KB Output is correct
17 Correct 11 ms 8524 KB Output is correct
18 Correct 23 ms 15480 KB Output is correct
19 Correct 1 ms 1620 KB Output is correct
20 Correct 1 ms 852 KB Output is correct
21 Correct 5 ms 4564 KB Output is correct
22 Correct 7 ms 5832 KB Output is correct
23 Correct 5 ms 4692 KB Output is correct
24 Correct 15 ms 10324 KB Output is correct
25 Correct 28 ms 17772 KB Output is correct
26 Correct 28 ms 15908 KB Output is correct
27 Correct 2 ms 1748 KB Output is correct
28 Correct 8 ms 5972 KB Output is correct
29 Correct 15 ms 1964 KB Output is correct
30 Correct 20 ms 6096 KB Output is correct
31 Correct 75 ms 12452 KB Output is correct
32 Correct 33 ms 10720 KB Output is correct
33 Correct 88 ms 18332 KB Output is correct
34 Correct 14 ms 2900 KB Output is correct
35 Correct 4 ms 1996 KB Output is correct
36 Correct 39 ms 3004 KB Output is correct
37 Correct 200 ms 25924 KB Output is correct
38 Correct 1510 ms 168160 KB Output is correct
39 Correct 222 ms 13332 KB Output is correct
40 Correct 603 ms 131788 KB Output is correct
41 Correct 1649 ms 216096 KB Output is correct
42 Correct 422 ms 29072 KB Output is correct
43 Correct 251 ms 63820 KB Output is correct
44 Correct 245 ms 63872 KB Output is correct