Submission #793890

# Submission time Handle Problem Language Result Execution time Memory
793890 2023-07-26T07:51:59 Z ymm IOI Fever (JOI21_fever) C++17
25 / 100
5000 ms 48460 KB
#include <bits/stdc++.h>
#define Loop(x,l,r) for (ll x = (l); x < (r); ++x)
typedef long long ll;
//typedef std::pair<int,int> pii;
using namespace std;

#define int ll

const int N = 100'010;
map<int,vector<int>> wa, as, sd, dw;
int X[N], Y[N];
int dis[N];
int n;

enum dir { W, A, S, D};
map<int,vector<int>> *dvec[4][2] = {
	{&dw, &wa},
	{&as, &wa},
	{&as, &sd},
	{&dw, &sd},
};

pair<int,dir> colide(int i, int j, dir d)
{
	int x = X[j] - X[i];
	int y = Y[j] - Y[i];
	assert(abs(x) == abs(y));
	switch (d) {
		case W: return {y, x > 0? A: D};
		case A: return {-x, y > 0? S: W};
		case S: return {-y, x > 0? A: D};
		case D: return {x, y > 0? S: W};
	}
}
dir disdir[N];

int dij(int v, dir d)
{
	fill(dis, dis+N, (ll)1e18);
	set<pair<int,int>> S;
	disdir[v] = d;
	dis[v] = 0;
	S.insert({dis[v], v});
	int ans = 0;
	while (S.size()) {
		++ans;
		int v = S.begin()->second;
		S.erase(S.begin());
		dir d = disdir[v];
		auto &vec1 = (*dvec[d][0])[X[v]-Y[v]];
		auto &vec2 = (*dvec[d][1])[X[v]+Y[v]];
		for (auto _vec : {&vec1, &vec2}) {
			auto &vec = *_vec;
			//while (vec.size()) {
			//	int u = vec.back();
			for (int u : vec) {
				auto [di, d2] = colide(v, u, d);
				if (di < dis[v])
					continue;
				if (di < dis[u]) {
					S.erase({dis[u], u});
					dis[u] = di;
					disdir[u] = d2;
					S.insert({dis[u], u});
				}
			}
		}
	}
	return ans;
	//return q.size();
}

signed main()
{
	cin.tie(0) -> sync_with_stdio(false);
	cin >> n;
	Loop (i,0,n)
		cin >> X[i] >> Y[i];
	Loop (i,1,n) {
		X[i] -= X[0];
		Y[i] -= Y[0];
	}
	X[0] = Y[0] = 0;
	int ans = 0;
	for (auto d : {W, A, S, D}) {
		for (auto mp : {&dw, &wa, &as, &sd})
			for (auto &[_, vec] : *mp)
				vec.clear();
		Loop (i,0,n) {
			dw[X[i]-Y[i]].push_back(i);
			wa[X[i]+Y[i]].push_back(i);
			as[X[i]-Y[i]].push_back(i);
			sd[X[i]+Y[i]].push_back(i);
		}
		for (auto &[_, vec] : dw) sort(vec.begin(), vec.end(), [&](int i, int j){ return X[i] < X[j]; });
		for (auto &[_, vec] : wa) sort(vec.begin(), vec.end(), [&](int i, int j){ return X[i] > X[j]; });
		for (auto &[_, vec] : as) sort(vec.begin(), vec.end(), [&](int i, int j){ return X[i] > X[j]; });
		for (auto &[_, vec] : sd) sort(vec.begin(), vec.end(), [&](int i, int j){ return X[i] < X[j]; });
		ans = max(ans, dij(0, d));
	}
	cout << ans << '\n';
}

Compilation message

fever.cpp: In function 'std::pair<long long int, dir> colide(ll, ll, dir)':
fever.cpp:34:1: warning: control reaches end of non-void function [-Wreturn-type]
   34 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1108 KB Output is correct
2 Correct 1 ms 1108 KB Output is correct
3 Correct 1 ms 1108 KB Output is correct
4 Correct 1 ms 1108 KB Output is correct
5 Correct 1 ms 1128 KB Output is correct
6 Correct 1 ms 1108 KB Output is correct
7 Correct 1 ms 1108 KB Output is correct
8 Correct 1 ms 1108 KB Output is correct
9 Correct 1 ms 1108 KB Output is correct
10 Correct 1 ms 1108 KB Output is correct
11 Correct 1 ms 1108 KB Output is correct
12 Correct 1 ms 1108 KB Output is correct
13 Correct 1 ms 1108 KB Output is correct
14 Correct 1 ms 1124 KB Output is correct
15 Correct 1 ms 1108 KB Output is correct
16 Correct 1 ms 1108 KB Output is correct
17 Correct 1 ms 1108 KB Output is correct
18 Correct 1 ms 1108 KB Output is correct
19 Correct 1 ms 1108 KB Output is correct
20 Correct 1 ms 1108 KB Output is correct
21 Correct 1 ms 1108 KB Output is correct
22 Correct 1 ms 1108 KB Output is correct
23 Correct 1 ms 1108 KB Output is correct
24 Correct 1 ms 1108 KB Output is correct
25 Correct 1 ms 1108 KB Output is correct
26 Correct 1 ms 1108 KB Output is correct
27 Correct 1 ms 1108 KB Output is correct
28 Correct 1 ms 1108 KB Output is correct
29 Correct 1 ms 1108 KB Output is correct
30 Correct 1 ms 1108 KB Output is correct
31 Correct 1 ms 1108 KB Output is correct
32 Correct 1 ms 1108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1108 KB Output is correct
2 Correct 1 ms 1108 KB Output is correct
3 Correct 1 ms 1108 KB Output is correct
4 Correct 1 ms 1108 KB Output is correct
5 Correct 1 ms 1128 KB Output is correct
6 Correct 1 ms 1108 KB Output is correct
7 Correct 1 ms 1108 KB Output is correct
8 Correct 1 ms 1108 KB Output is correct
9 Correct 1 ms 1108 KB Output is correct
10 Correct 1 ms 1108 KB Output is correct
11 Correct 1 ms 1108 KB Output is correct
12 Correct 1 ms 1108 KB Output is correct
13 Correct 1 ms 1108 KB Output is correct
14 Correct 1 ms 1124 KB Output is correct
15 Correct 1 ms 1108 KB Output is correct
16 Correct 1 ms 1108 KB Output is correct
17 Correct 1 ms 1108 KB Output is correct
18 Correct 1 ms 1108 KB Output is correct
19 Correct 1 ms 1108 KB Output is correct
20 Correct 1 ms 1108 KB Output is correct
21 Correct 1 ms 1108 KB Output is correct
22 Correct 1 ms 1108 KB Output is correct
23 Correct 1 ms 1108 KB Output is correct
24 Correct 1 ms 1108 KB Output is correct
25 Correct 1 ms 1108 KB Output is correct
26 Correct 1 ms 1108 KB Output is correct
27 Correct 1 ms 1108 KB Output is correct
28 Correct 1 ms 1108 KB Output is correct
29 Correct 1 ms 1108 KB Output is correct
30 Correct 1 ms 1108 KB Output is correct
31 Correct 1 ms 1108 KB Output is correct
32 Correct 1 ms 1108 KB Output is correct
33 Correct 1 ms 1096 KB Output is correct
34 Correct 1 ms 1096 KB Output is correct
35 Correct 2 ms 1096 KB Output is correct
36 Correct 1 ms 1108 KB Output is correct
37 Correct 1 ms 1108 KB Output is correct
38 Correct 1 ms 1108 KB Output is correct
39 Correct 1 ms 1108 KB Output is correct
40 Correct 1 ms 1144 KB Output is correct
41 Correct 1 ms 1108 KB Output is correct
42 Correct 1 ms 1108 KB Output is correct
43 Correct 1 ms 1108 KB Output is correct
44 Correct 1 ms 1108 KB Output is correct
45 Correct 1 ms 1108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1108 KB Output is correct
2 Correct 1 ms 1108 KB Output is correct
3 Correct 1 ms 1108 KB Output is correct
4 Correct 1 ms 1108 KB Output is correct
5 Correct 1 ms 1108 KB Output is correct
6 Correct 1 ms 1108 KB Output is correct
7 Correct 1 ms 1108 KB Output is correct
8 Correct 1 ms 1108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1108 KB Output is correct
2 Correct 1 ms 1108 KB Output is correct
3 Correct 1 ms 1108 KB Output is correct
4 Correct 1 ms 1108 KB Output is correct
5 Correct 1 ms 1128 KB Output is correct
6 Correct 1 ms 1108 KB Output is correct
7 Correct 1 ms 1108 KB Output is correct
8 Correct 1 ms 1108 KB Output is correct
9 Correct 1 ms 1108 KB Output is correct
10 Correct 1 ms 1108 KB Output is correct
11 Correct 1 ms 1108 KB Output is correct
12 Correct 1 ms 1108 KB Output is correct
13 Correct 1 ms 1108 KB Output is correct
14 Correct 1 ms 1124 KB Output is correct
15 Correct 1 ms 1108 KB Output is correct
16 Correct 1 ms 1108 KB Output is correct
17 Correct 1 ms 1108 KB Output is correct
18 Correct 1 ms 1108 KB Output is correct
19 Correct 1 ms 1108 KB Output is correct
20 Correct 1 ms 1108 KB Output is correct
21 Correct 1 ms 1108 KB Output is correct
22 Correct 1 ms 1108 KB Output is correct
23 Correct 1 ms 1108 KB Output is correct
24 Correct 1 ms 1108 KB Output is correct
25 Correct 1 ms 1108 KB Output is correct
26 Correct 1 ms 1108 KB Output is correct
27 Correct 1 ms 1108 KB Output is correct
28 Correct 1 ms 1108 KB Output is correct
29 Correct 1 ms 1108 KB Output is correct
30 Correct 1 ms 1108 KB Output is correct
31 Correct 1 ms 1108 KB Output is correct
32 Correct 1 ms 1108 KB Output is correct
33 Correct 1 ms 1096 KB Output is correct
34 Correct 1 ms 1096 KB Output is correct
35 Correct 2 ms 1096 KB Output is correct
36 Correct 1 ms 1108 KB Output is correct
37 Correct 1 ms 1108 KB Output is correct
38 Correct 1 ms 1108 KB Output is correct
39 Correct 1 ms 1108 KB Output is correct
40 Correct 1 ms 1144 KB Output is correct
41 Correct 1 ms 1108 KB Output is correct
42 Correct 1 ms 1108 KB Output is correct
43 Correct 1 ms 1108 KB Output is correct
44 Correct 1 ms 1108 KB Output is correct
45 Correct 1 ms 1108 KB Output is correct
46 Correct 1 ms 1108 KB Output is correct
47 Correct 1 ms 1108 KB Output is correct
48 Correct 1 ms 1108 KB Output is correct
49 Correct 1 ms 1108 KB Output is correct
50 Correct 1 ms 1108 KB Output is correct
51 Correct 1 ms 1108 KB Output is correct
52 Correct 1 ms 1108 KB Output is correct
53 Correct 1 ms 1108 KB Output is correct
54 Correct 1 ms 1108 KB Output is correct
55 Correct 1 ms 1108 KB Output is correct
56 Correct 1 ms 1108 KB Output is correct
57 Correct 2 ms 1092 KB Output is correct
58 Correct 1 ms 1108 KB Output is correct
59 Correct 2 ms 1108 KB Output is correct
60 Correct 2 ms 1108 KB Output is correct
61 Correct 1 ms 1108 KB Output is correct
62 Correct 2 ms 1108 KB Output is correct
63 Correct 1 ms 1108 KB Output is correct
64 Correct 1 ms 1108 KB Output is correct
65 Correct 1 ms 1108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1108 KB Output is correct
2 Correct 1 ms 1108 KB Output is correct
3 Correct 1 ms 1108 KB Output is correct
4 Correct 1 ms 1108 KB Output is correct
5 Correct 1 ms 1128 KB Output is correct
6 Correct 1 ms 1108 KB Output is correct
7 Correct 1 ms 1108 KB Output is correct
8 Correct 1 ms 1108 KB Output is correct
9 Correct 1 ms 1108 KB Output is correct
10 Correct 1 ms 1108 KB Output is correct
11 Correct 1 ms 1108 KB Output is correct
12 Correct 1 ms 1108 KB Output is correct
13 Correct 1 ms 1108 KB Output is correct
14 Correct 1 ms 1124 KB Output is correct
15 Correct 1 ms 1108 KB Output is correct
16 Correct 1 ms 1108 KB Output is correct
17 Correct 1 ms 1108 KB Output is correct
18 Correct 1 ms 1108 KB Output is correct
19 Correct 1 ms 1108 KB Output is correct
20 Correct 1 ms 1108 KB Output is correct
21 Correct 1 ms 1108 KB Output is correct
22 Correct 1 ms 1108 KB Output is correct
23 Correct 1 ms 1108 KB Output is correct
24 Correct 1 ms 1108 KB Output is correct
25 Correct 1 ms 1108 KB Output is correct
26 Correct 1 ms 1108 KB Output is correct
27 Correct 1 ms 1108 KB Output is correct
28 Correct 1 ms 1108 KB Output is correct
29 Correct 1 ms 1108 KB Output is correct
30 Correct 1 ms 1108 KB Output is correct
31 Correct 1 ms 1108 KB Output is correct
32 Correct 1 ms 1108 KB Output is correct
33 Correct 1 ms 1096 KB Output is correct
34 Correct 1 ms 1096 KB Output is correct
35 Correct 2 ms 1096 KB Output is correct
36 Correct 1 ms 1108 KB Output is correct
37 Correct 1 ms 1108 KB Output is correct
38 Correct 1 ms 1108 KB Output is correct
39 Correct 1 ms 1108 KB Output is correct
40 Correct 1 ms 1144 KB Output is correct
41 Correct 1 ms 1108 KB Output is correct
42 Correct 1 ms 1108 KB Output is correct
43 Correct 1 ms 1108 KB Output is correct
44 Correct 1 ms 1108 KB Output is correct
45 Correct 1 ms 1108 KB Output is correct
46 Correct 1 ms 1108 KB Output is correct
47 Correct 1 ms 1108 KB Output is correct
48 Correct 1 ms 1108 KB Output is correct
49 Correct 1 ms 1108 KB Output is correct
50 Correct 1 ms 1108 KB Output is correct
51 Correct 1 ms 1108 KB Output is correct
52 Correct 1 ms 1108 KB Output is correct
53 Correct 1 ms 1108 KB Output is correct
54 Correct 1 ms 1108 KB Output is correct
55 Correct 1 ms 1108 KB Output is correct
56 Correct 1 ms 1108 KB Output is correct
57 Correct 2 ms 1092 KB Output is correct
58 Correct 1 ms 1108 KB Output is correct
59 Correct 2 ms 1108 KB Output is correct
60 Correct 2 ms 1108 KB Output is correct
61 Correct 1 ms 1108 KB Output is correct
62 Correct 2 ms 1108 KB Output is correct
63 Correct 1 ms 1108 KB Output is correct
64 Correct 1 ms 1108 KB Output is correct
65 Correct 1 ms 1108 KB Output is correct
66 Correct 9 ms 2132 KB Output is correct
67 Correct 11 ms 2132 KB Output is correct
68 Correct 9 ms 2540 KB Output is correct
69 Incorrect 9 ms 1364 KB Output isn't correct
70 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1108 KB Output is correct
2 Correct 1 ms 1108 KB Output is correct
3 Correct 1 ms 1108 KB Output is correct
4 Correct 1 ms 1108 KB Output is correct
5 Correct 1 ms 1128 KB Output is correct
6 Correct 1 ms 1108 KB Output is correct
7 Correct 1 ms 1108 KB Output is correct
8 Correct 1 ms 1108 KB Output is correct
9 Correct 1 ms 1108 KB Output is correct
10 Correct 1 ms 1108 KB Output is correct
11 Correct 1 ms 1108 KB Output is correct
12 Correct 1 ms 1108 KB Output is correct
13 Correct 1 ms 1108 KB Output is correct
14 Correct 1 ms 1124 KB Output is correct
15 Correct 1 ms 1108 KB Output is correct
16 Correct 1 ms 1108 KB Output is correct
17 Correct 1 ms 1108 KB Output is correct
18 Correct 1 ms 1108 KB Output is correct
19 Correct 1 ms 1108 KB Output is correct
20 Correct 1 ms 1108 KB Output is correct
21 Correct 1 ms 1108 KB Output is correct
22 Correct 1 ms 1108 KB Output is correct
23 Correct 1 ms 1108 KB Output is correct
24 Correct 1 ms 1108 KB Output is correct
25 Correct 1 ms 1108 KB Output is correct
26 Correct 1 ms 1108 KB Output is correct
27 Correct 1 ms 1108 KB Output is correct
28 Correct 1 ms 1108 KB Output is correct
29 Correct 1 ms 1108 KB Output is correct
30 Correct 1 ms 1108 KB Output is correct
31 Correct 1 ms 1108 KB Output is correct
32 Correct 1 ms 1108 KB Output is correct
33 Correct 1 ms 1096 KB Output is correct
34 Correct 1 ms 1096 KB Output is correct
35 Correct 2 ms 1096 KB Output is correct
36 Correct 1 ms 1108 KB Output is correct
37 Correct 1 ms 1108 KB Output is correct
38 Correct 1 ms 1108 KB Output is correct
39 Correct 1 ms 1108 KB Output is correct
40 Correct 1 ms 1144 KB Output is correct
41 Correct 1 ms 1108 KB Output is correct
42 Correct 1 ms 1108 KB Output is correct
43 Correct 1 ms 1108 KB Output is correct
44 Correct 1 ms 1108 KB Output is correct
45 Correct 1 ms 1108 KB Output is correct
46 Correct 1 ms 1108 KB Output is correct
47 Correct 1 ms 1108 KB Output is correct
48 Correct 1 ms 1108 KB Output is correct
49 Correct 1 ms 1108 KB Output is correct
50 Correct 1 ms 1108 KB Output is correct
51 Correct 1 ms 1108 KB Output is correct
52 Correct 1 ms 1108 KB Output is correct
53 Correct 1 ms 1108 KB Output is correct
54 Correct 1 ms 1108 KB Output is correct
55 Correct 1 ms 1108 KB Output is correct
56 Correct 1 ms 1108 KB Output is correct
57 Correct 2 ms 1092 KB Output is correct
58 Correct 1 ms 1108 KB Output is correct
59 Correct 2 ms 1108 KB Output is correct
60 Correct 2 ms 1108 KB Output is correct
61 Correct 1 ms 1108 KB Output is correct
62 Correct 2 ms 1108 KB Output is correct
63 Correct 1 ms 1108 KB Output is correct
64 Correct 1 ms 1108 KB Output is correct
65 Correct 1 ms 1108 KB Output is correct
66 Correct 699 ms 29344 KB Output is correct
67 Correct 936 ms 36388 KB Output is correct
68 Correct 1190 ms 48460 KB Output is correct
69 Execution timed out 5081 ms 33860 KB Time limit exceeded
70 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1108 KB Output is correct
2 Correct 1 ms 1108 KB Output is correct
3 Correct 1 ms 1108 KB Output is correct
4 Correct 1 ms 1108 KB Output is correct
5 Correct 1 ms 1128 KB Output is correct
6 Correct 1 ms 1108 KB Output is correct
7 Correct 1 ms 1108 KB Output is correct
8 Correct 1 ms 1108 KB Output is correct
9 Correct 1 ms 1108 KB Output is correct
10 Correct 1 ms 1108 KB Output is correct
11 Correct 1 ms 1108 KB Output is correct
12 Correct 1 ms 1108 KB Output is correct
13 Correct 1 ms 1108 KB Output is correct
14 Correct 1 ms 1124 KB Output is correct
15 Correct 1 ms 1108 KB Output is correct
16 Correct 1 ms 1108 KB Output is correct
17 Correct 1 ms 1108 KB Output is correct
18 Correct 1 ms 1108 KB Output is correct
19 Correct 1 ms 1108 KB Output is correct
20 Correct 1 ms 1108 KB Output is correct
21 Correct 1 ms 1108 KB Output is correct
22 Correct 1 ms 1108 KB Output is correct
23 Correct 1 ms 1108 KB Output is correct
24 Correct 1 ms 1108 KB Output is correct
25 Correct 1 ms 1108 KB Output is correct
26 Correct 1 ms 1108 KB Output is correct
27 Correct 1 ms 1108 KB Output is correct
28 Correct 1 ms 1108 KB Output is correct
29 Correct 1 ms 1108 KB Output is correct
30 Correct 1 ms 1108 KB Output is correct
31 Correct 1 ms 1108 KB Output is correct
32 Correct 1 ms 1108 KB Output is correct
33 Correct 1 ms 1096 KB Output is correct
34 Correct 1 ms 1096 KB Output is correct
35 Correct 2 ms 1096 KB Output is correct
36 Correct 1 ms 1108 KB Output is correct
37 Correct 1 ms 1108 KB Output is correct
38 Correct 1 ms 1108 KB Output is correct
39 Correct 1 ms 1108 KB Output is correct
40 Correct 1 ms 1144 KB Output is correct
41 Correct 1 ms 1108 KB Output is correct
42 Correct 1 ms 1108 KB Output is correct
43 Correct 1 ms 1108 KB Output is correct
44 Correct 1 ms 1108 KB Output is correct
45 Correct 1 ms 1108 KB Output is correct
46 Correct 1 ms 1108 KB Output is correct
47 Correct 1 ms 1108 KB Output is correct
48 Correct 1 ms 1108 KB Output is correct
49 Correct 1 ms 1108 KB Output is correct
50 Correct 1 ms 1108 KB Output is correct
51 Correct 1 ms 1108 KB Output is correct
52 Correct 1 ms 1108 KB Output is correct
53 Correct 1 ms 1108 KB Output is correct
54 Correct 1 ms 1108 KB Output is correct
55 Correct 1 ms 1108 KB Output is correct
56 Correct 1 ms 1108 KB Output is correct
57 Correct 2 ms 1092 KB Output is correct
58 Correct 1 ms 1108 KB Output is correct
59 Correct 2 ms 1108 KB Output is correct
60 Correct 2 ms 1108 KB Output is correct
61 Correct 1 ms 1108 KB Output is correct
62 Correct 2 ms 1108 KB Output is correct
63 Correct 1 ms 1108 KB Output is correct
64 Correct 1 ms 1108 KB Output is correct
65 Correct 1 ms 1108 KB Output is correct
66 Correct 9 ms 2132 KB Output is correct
67 Correct 11 ms 2132 KB Output is correct
68 Correct 9 ms 2540 KB Output is correct
69 Incorrect 9 ms 1364 KB Output isn't correct
70 Halted 0 ms 0 KB -