Submission #953178

# Submission time Handle Problem Language Result Execution time Memory
953178 2024-03-25T15:52:34 Z WonderfulWhale IOI Fever (JOI21_fever) C++17
25 / 100
5000 ms 14308 KB
#include<bits/stdc++.h>
using namespace std;

#define int int64_t
#define pb push_back
#define pii pair<int, int>
#define st first
#define nd second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

ostream& operator<<(ostream &os, pair<auto, auto> x) {
	os << "{" << x.st << ", " << x.nd << "}";
	return os;
}

const int MAXN = 100'009;

pii tab[MAXN];
int dis[MAXN];
int dir[MAXN];
vector<int> G[MAXN][4];
int n;

int f(int a, int b) {
	return abs(tab[a].st-tab[b].st)+abs(tab[a].nd-tab[b].nd);
}

int dijkstra(int s, int s_dir) {
	fill(dis, dis+n, 2e9);
	fill(dir, dir+n, -1);
	int cnt = 0;
	dis[s] = 0;
	dir[s] = s_dir;
	priority_queue<pii, vector<pii>, greater<pii>> Q;
	Q.push({dis[s], s});
	while(sz(Q)) {
		auto [d_x, x] = Q.top();
		Q.pop();
		if(d_x!=dis[x]) continue;
		cnt++;
		// cerr << "dij: " << tab[x] << " " << d_x << "\n";
		for(int y:G[x][dir[x]]) {
			// cerr << "one: " << tab[y] << "\n";
			int d = f(x, y);
			if(d<d_x) continue;
			if(d<dis[y]) {
				dis[y] = d;
				int ndir = (dir[x]+1)%4;
				assert(dir[y]==-1||dir[y]==ndir);
				dir[y] = ndir;
				Q.push({dis[y], y});
			}
		}
		for(int y:G[x][(dir[x]+1)%4]) {
			// cerr << "two: " << tab[y] << "\n";
			int d = f(x, y);
			// cout << tab[x] << " " << tab[y] << " " << d << "\n";
			if(d<d_x) continue;
			if(d<dis[y]) {
				dis[y] = d;
				int ndir = dir[x]-1;
				if(ndir<0) ndir+=4;
				assert(dir[y]==-1||dir[y]==ndir);
				dir[y] = ndir;
				Q.push({dis[y], y});
			}
		}
	}
	return cnt;
}

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n;
	int ANS = 0;
	for(int i=0;i<n;i++) {
		int a, b;
		cin >> a >> b;
		// tab[i] = {a, b};
		tab[i] = {a+b, a-b};
		if(a==b) ANS++;
		// cerr << i << ": " << tab[i] << "\n";
	}
	for(int i=0;i<n;i++) {
		auto [a1, b1] = tab[i];
		// if(i==0) cerr << "TU: " << tab[i] << "\n";
		for(int j=0;j<n;j++) {
			auto [a2, b2] = tab[j];
			if(a1<a2&&b1==b2) {
				// if(i==0) cerr << "0: " << tab[j] << "\n";
				G[i][0].pb(j);
			}
			if(a1==a2&&b2>b1) {
				// if(i==0) cerr << "1: " << tab[j] << "\n";
				G[i][1].pb(j);
			}
			if(a1>a2&&b1==b2) {
				// if(i==0) cerr << "2: " << tab[j] << "\n";
				G[i][2].pb(j);
			}
			if(a1==a2&&b2<b1) {
				// if(i==0) cerr << "3: " << tab[j] << "\n";
				G[i][3].pb(j);
			}
		}
	}
	int ans = 0;
	// ans = dijkstra(0, 0);
	for(int i=0;i<4;i++) {
		ans = max(ans, dijkstra(0, i));
	}
	// cout << ans << "\n";
	cout << ans << "\n";
}

Compilation message

fever.cpp:12:39: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   12 | ostream& operator<<(ostream &os, pair<auto, auto> x) {
      |                                       ^~~~
fever.cpp:12:45: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   12 | ostream& operator<<(ostream &os, pair<auto, auto> x) {
      |                                             ^~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 12888 KB Output is correct
2 Correct 2 ms 12892 KB Output is correct
3 Correct 2 ms 12892 KB Output is correct
4 Correct 3 ms 12888 KB Output is correct
5 Correct 4 ms 12892 KB Output is correct
6 Correct 3 ms 12892 KB Output is correct
7 Correct 3 ms 12908 KB Output is correct
8 Correct 2 ms 12892 KB Output is correct
9 Correct 3 ms 12892 KB Output is correct
10 Correct 3 ms 12892 KB Output is correct
11 Correct 3 ms 12892 KB Output is correct
12 Correct 3 ms 13144 KB Output is correct
13 Correct 3 ms 12892 KB Output is correct
14 Correct 3 ms 12892 KB Output is correct
15 Correct 2 ms 12892 KB Output is correct
16 Correct 2 ms 12892 KB Output is correct
17 Correct 4 ms 12892 KB Output is correct
18 Correct 2 ms 12892 KB Output is correct
19 Correct 3 ms 12892 KB Output is correct
20 Correct 3 ms 12888 KB Output is correct
21 Correct 2 ms 12892 KB Output is correct
22 Correct 3 ms 12896 KB Output is correct
23 Correct 3 ms 12892 KB Output is correct
24 Correct 3 ms 12892 KB Output is correct
25 Correct 4 ms 12892 KB Output is correct
26 Correct 2 ms 12888 KB Output is correct
27 Correct 4 ms 12892 KB Output is correct
28 Correct 3 ms 12888 KB Output is correct
29 Correct 2 ms 12892 KB Output is correct
30 Correct 3 ms 12892 KB Output is correct
31 Correct 3 ms 12892 KB Output is correct
32 Correct 3 ms 12892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 12888 KB Output is correct
2 Correct 2 ms 12892 KB Output is correct
3 Correct 2 ms 12892 KB Output is correct
4 Correct 3 ms 12888 KB Output is correct
5 Correct 4 ms 12892 KB Output is correct
6 Correct 3 ms 12892 KB Output is correct
7 Correct 3 ms 12908 KB Output is correct
8 Correct 2 ms 12892 KB Output is correct
9 Correct 3 ms 12892 KB Output is correct
10 Correct 3 ms 12892 KB Output is correct
11 Correct 3 ms 12892 KB Output is correct
12 Correct 3 ms 13144 KB Output is correct
13 Correct 3 ms 12892 KB Output is correct
14 Correct 3 ms 12892 KB Output is correct
15 Correct 2 ms 12892 KB Output is correct
16 Correct 2 ms 12892 KB Output is correct
17 Correct 4 ms 12892 KB Output is correct
18 Correct 2 ms 12892 KB Output is correct
19 Correct 3 ms 12892 KB Output is correct
20 Correct 3 ms 12888 KB Output is correct
21 Correct 2 ms 12892 KB Output is correct
22 Correct 3 ms 12896 KB Output is correct
23 Correct 3 ms 12892 KB Output is correct
24 Correct 3 ms 12892 KB Output is correct
25 Correct 4 ms 12892 KB Output is correct
26 Correct 2 ms 12888 KB Output is correct
27 Correct 4 ms 12892 KB Output is correct
28 Correct 3 ms 12888 KB Output is correct
29 Correct 2 ms 12892 KB Output is correct
30 Correct 3 ms 12892 KB Output is correct
31 Correct 3 ms 12892 KB Output is correct
32 Correct 3 ms 12892 KB Output is correct
33 Correct 2 ms 12892 KB Output is correct
34 Correct 2 ms 12888 KB Output is correct
35 Correct 2 ms 12888 KB Output is correct
36 Correct 2 ms 12892 KB Output is correct
37 Correct 2 ms 12892 KB Output is correct
38 Correct 4 ms 12892 KB Output is correct
39 Correct 2 ms 12892 KB Output is correct
40 Correct 2 ms 12892 KB Output is correct
41 Correct 2 ms 12892 KB Output is correct
42 Correct 3 ms 12892 KB Output is correct
43 Correct 2 ms 12892 KB Output is correct
44 Correct 3 ms 12892 KB Output is correct
45 Correct 3 ms 12892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 12892 KB Output is correct
2 Correct 2 ms 12892 KB Output is correct
3 Correct 3 ms 12908 KB Output is correct
4 Correct 2 ms 12892 KB Output is correct
5 Correct 3 ms 12888 KB Output is correct
6 Correct 3 ms 12892 KB Output is correct
7 Correct 3 ms 12892 KB Output is correct
8 Correct 3 ms 12892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 12888 KB Output is correct
2 Correct 2 ms 12892 KB Output is correct
3 Correct 2 ms 12892 KB Output is correct
4 Correct 3 ms 12888 KB Output is correct
5 Correct 4 ms 12892 KB Output is correct
6 Correct 3 ms 12892 KB Output is correct
7 Correct 3 ms 12908 KB Output is correct
8 Correct 2 ms 12892 KB Output is correct
9 Correct 3 ms 12892 KB Output is correct
10 Correct 3 ms 12892 KB Output is correct
11 Correct 3 ms 12892 KB Output is correct
12 Correct 3 ms 13144 KB Output is correct
13 Correct 3 ms 12892 KB Output is correct
14 Correct 3 ms 12892 KB Output is correct
15 Correct 2 ms 12892 KB Output is correct
16 Correct 2 ms 12892 KB Output is correct
17 Correct 4 ms 12892 KB Output is correct
18 Correct 2 ms 12892 KB Output is correct
19 Correct 3 ms 12892 KB Output is correct
20 Correct 3 ms 12888 KB Output is correct
21 Correct 2 ms 12892 KB Output is correct
22 Correct 3 ms 12896 KB Output is correct
23 Correct 3 ms 12892 KB Output is correct
24 Correct 3 ms 12892 KB Output is correct
25 Correct 4 ms 12892 KB Output is correct
26 Correct 2 ms 12888 KB Output is correct
27 Correct 4 ms 12892 KB Output is correct
28 Correct 3 ms 12888 KB Output is correct
29 Correct 2 ms 12892 KB Output is correct
30 Correct 3 ms 12892 KB Output is correct
31 Correct 3 ms 12892 KB Output is correct
32 Correct 3 ms 12892 KB Output is correct
33 Correct 2 ms 12892 KB Output is correct
34 Correct 2 ms 12888 KB Output is correct
35 Correct 2 ms 12888 KB Output is correct
36 Correct 2 ms 12892 KB Output is correct
37 Correct 2 ms 12892 KB Output is correct
38 Correct 4 ms 12892 KB Output is correct
39 Correct 2 ms 12892 KB Output is correct
40 Correct 2 ms 12892 KB Output is correct
41 Correct 2 ms 12892 KB Output is correct
42 Correct 3 ms 12892 KB Output is correct
43 Correct 2 ms 12892 KB Output is correct
44 Correct 3 ms 12892 KB Output is correct
45 Correct 3 ms 12892 KB Output is correct
46 Correct 4 ms 12892 KB Output is correct
47 Correct 2 ms 12892 KB Output is correct
48 Correct 3 ms 12908 KB Output is correct
49 Correct 2 ms 12892 KB Output is correct
50 Correct 3 ms 12888 KB Output is correct
51 Correct 3 ms 12892 KB Output is correct
52 Correct 3 ms 12892 KB Output is correct
53 Correct 3 ms 12892 KB Output is correct
54 Correct 3 ms 12888 KB Output is correct
55 Correct 2 ms 12892 KB Output is correct
56 Correct 3 ms 12892 KB Output is correct
57 Correct 3 ms 12892 KB Output is correct
58 Correct 3 ms 12892 KB Output is correct
59 Correct 3 ms 12892 KB Output is correct
60 Correct 3 ms 12892 KB Output is correct
61 Correct 4 ms 12972 KB Output is correct
62 Correct 3 ms 12892 KB Output is correct
63 Correct 2 ms 12892 KB Output is correct
64 Correct 4 ms 12892 KB Output is correct
65 Correct 3 ms 12892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 12888 KB Output is correct
2 Correct 2 ms 12892 KB Output is correct
3 Correct 2 ms 12892 KB Output is correct
4 Correct 3 ms 12888 KB Output is correct
5 Correct 4 ms 12892 KB Output is correct
6 Correct 3 ms 12892 KB Output is correct
7 Correct 3 ms 12908 KB Output is correct
8 Correct 2 ms 12892 KB Output is correct
9 Correct 3 ms 12892 KB Output is correct
10 Correct 3 ms 12892 KB Output is correct
11 Correct 3 ms 12892 KB Output is correct
12 Correct 3 ms 13144 KB Output is correct
13 Correct 3 ms 12892 KB Output is correct
14 Correct 3 ms 12892 KB Output is correct
15 Correct 2 ms 12892 KB Output is correct
16 Correct 2 ms 12892 KB Output is correct
17 Correct 4 ms 12892 KB Output is correct
18 Correct 2 ms 12892 KB Output is correct
19 Correct 3 ms 12892 KB Output is correct
20 Correct 3 ms 12888 KB Output is correct
21 Correct 2 ms 12892 KB Output is correct
22 Correct 3 ms 12896 KB Output is correct
23 Correct 3 ms 12892 KB Output is correct
24 Correct 3 ms 12892 KB Output is correct
25 Correct 4 ms 12892 KB Output is correct
26 Correct 2 ms 12888 KB Output is correct
27 Correct 4 ms 12892 KB Output is correct
28 Correct 3 ms 12888 KB Output is correct
29 Correct 2 ms 12892 KB Output is correct
30 Correct 3 ms 12892 KB Output is correct
31 Correct 3 ms 12892 KB Output is correct
32 Correct 3 ms 12892 KB Output is correct
33 Correct 2 ms 12892 KB Output is correct
34 Correct 2 ms 12888 KB Output is correct
35 Correct 2 ms 12888 KB Output is correct
36 Correct 2 ms 12892 KB Output is correct
37 Correct 2 ms 12892 KB Output is correct
38 Correct 4 ms 12892 KB Output is correct
39 Correct 2 ms 12892 KB Output is correct
40 Correct 2 ms 12892 KB Output is correct
41 Correct 2 ms 12892 KB Output is correct
42 Correct 3 ms 12892 KB Output is correct
43 Correct 2 ms 12892 KB Output is correct
44 Correct 3 ms 12892 KB Output is correct
45 Correct 3 ms 12892 KB Output is correct
46 Correct 4 ms 12892 KB Output is correct
47 Correct 2 ms 12892 KB Output is correct
48 Correct 3 ms 12908 KB Output is correct
49 Correct 2 ms 12892 KB Output is correct
50 Correct 3 ms 12888 KB Output is correct
51 Correct 3 ms 12892 KB Output is correct
52 Correct 3 ms 12892 KB Output is correct
53 Correct 3 ms 12892 KB Output is correct
54 Correct 3 ms 12888 KB Output is correct
55 Correct 2 ms 12892 KB Output is correct
56 Correct 3 ms 12892 KB Output is correct
57 Correct 3 ms 12892 KB Output is correct
58 Correct 3 ms 12892 KB Output is correct
59 Correct 3 ms 12892 KB Output is correct
60 Correct 3 ms 12892 KB Output is correct
61 Correct 4 ms 12972 KB Output is correct
62 Correct 3 ms 12892 KB Output is correct
63 Correct 2 ms 12892 KB Output is correct
64 Correct 4 ms 12892 KB Output is correct
65 Correct 3 ms 12892 KB Output is correct
66 Correct 32 ms 12984 KB Output is correct
67 Correct 31 ms 12888 KB Output is correct
68 Correct 31 ms 12892 KB Output is correct
69 Incorrect 39 ms 14308 KB Output isn't correct
70 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 12888 KB Output is correct
2 Correct 2 ms 12892 KB Output is correct
3 Correct 2 ms 12892 KB Output is correct
4 Correct 3 ms 12888 KB Output is correct
5 Correct 4 ms 12892 KB Output is correct
6 Correct 3 ms 12892 KB Output is correct
7 Correct 3 ms 12908 KB Output is correct
8 Correct 2 ms 12892 KB Output is correct
9 Correct 3 ms 12892 KB Output is correct
10 Correct 3 ms 12892 KB Output is correct
11 Correct 3 ms 12892 KB Output is correct
12 Correct 3 ms 13144 KB Output is correct
13 Correct 3 ms 12892 KB Output is correct
14 Correct 3 ms 12892 KB Output is correct
15 Correct 2 ms 12892 KB Output is correct
16 Correct 2 ms 12892 KB Output is correct
17 Correct 4 ms 12892 KB Output is correct
18 Correct 2 ms 12892 KB Output is correct
19 Correct 3 ms 12892 KB Output is correct
20 Correct 3 ms 12888 KB Output is correct
21 Correct 2 ms 12892 KB Output is correct
22 Correct 3 ms 12896 KB Output is correct
23 Correct 3 ms 12892 KB Output is correct
24 Correct 3 ms 12892 KB Output is correct
25 Correct 4 ms 12892 KB Output is correct
26 Correct 2 ms 12888 KB Output is correct
27 Correct 4 ms 12892 KB Output is correct
28 Correct 3 ms 12888 KB Output is correct
29 Correct 2 ms 12892 KB Output is correct
30 Correct 3 ms 12892 KB Output is correct
31 Correct 3 ms 12892 KB Output is correct
32 Correct 3 ms 12892 KB Output is correct
33 Correct 2 ms 12892 KB Output is correct
34 Correct 2 ms 12888 KB Output is correct
35 Correct 2 ms 12888 KB Output is correct
36 Correct 2 ms 12892 KB Output is correct
37 Correct 2 ms 12892 KB Output is correct
38 Correct 4 ms 12892 KB Output is correct
39 Correct 2 ms 12892 KB Output is correct
40 Correct 2 ms 12892 KB Output is correct
41 Correct 2 ms 12892 KB Output is correct
42 Correct 3 ms 12892 KB Output is correct
43 Correct 2 ms 12892 KB Output is correct
44 Correct 3 ms 12892 KB Output is correct
45 Correct 3 ms 12892 KB Output is correct
46 Correct 4 ms 12892 KB Output is correct
47 Correct 2 ms 12892 KB Output is correct
48 Correct 3 ms 12908 KB Output is correct
49 Correct 2 ms 12892 KB Output is correct
50 Correct 3 ms 12888 KB Output is correct
51 Correct 3 ms 12892 KB Output is correct
52 Correct 3 ms 12892 KB Output is correct
53 Correct 3 ms 12892 KB Output is correct
54 Correct 3 ms 12888 KB Output is correct
55 Correct 2 ms 12892 KB Output is correct
56 Correct 3 ms 12892 KB Output is correct
57 Correct 3 ms 12892 KB Output is correct
58 Correct 3 ms 12892 KB Output is correct
59 Correct 3 ms 12892 KB Output is correct
60 Correct 3 ms 12892 KB Output is correct
61 Correct 4 ms 12972 KB Output is correct
62 Correct 3 ms 12892 KB Output is correct
63 Correct 2 ms 12892 KB Output is correct
64 Correct 4 ms 12892 KB Output is correct
65 Correct 3 ms 12892 KB Output is correct
66 Execution timed out 5057 ms 13820 KB Time limit exceeded
67 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 12888 KB Output is correct
2 Correct 2 ms 12892 KB Output is correct
3 Correct 2 ms 12892 KB Output is correct
4 Correct 3 ms 12888 KB Output is correct
5 Correct 4 ms 12892 KB Output is correct
6 Correct 3 ms 12892 KB Output is correct
7 Correct 3 ms 12908 KB Output is correct
8 Correct 2 ms 12892 KB Output is correct
9 Correct 3 ms 12892 KB Output is correct
10 Correct 3 ms 12892 KB Output is correct
11 Correct 3 ms 12892 KB Output is correct
12 Correct 3 ms 13144 KB Output is correct
13 Correct 3 ms 12892 KB Output is correct
14 Correct 3 ms 12892 KB Output is correct
15 Correct 2 ms 12892 KB Output is correct
16 Correct 2 ms 12892 KB Output is correct
17 Correct 4 ms 12892 KB Output is correct
18 Correct 2 ms 12892 KB Output is correct
19 Correct 3 ms 12892 KB Output is correct
20 Correct 3 ms 12888 KB Output is correct
21 Correct 2 ms 12892 KB Output is correct
22 Correct 3 ms 12896 KB Output is correct
23 Correct 3 ms 12892 KB Output is correct
24 Correct 3 ms 12892 KB Output is correct
25 Correct 4 ms 12892 KB Output is correct
26 Correct 2 ms 12888 KB Output is correct
27 Correct 4 ms 12892 KB Output is correct
28 Correct 3 ms 12888 KB Output is correct
29 Correct 2 ms 12892 KB Output is correct
30 Correct 3 ms 12892 KB Output is correct
31 Correct 3 ms 12892 KB Output is correct
32 Correct 3 ms 12892 KB Output is correct
33 Correct 2 ms 12892 KB Output is correct
34 Correct 2 ms 12888 KB Output is correct
35 Correct 2 ms 12888 KB Output is correct
36 Correct 2 ms 12892 KB Output is correct
37 Correct 2 ms 12892 KB Output is correct
38 Correct 4 ms 12892 KB Output is correct
39 Correct 2 ms 12892 KB Output is correct
40 Correct 2 ms 12892 KB Output is correct
41 Correct 2 ms 12892 KB Output is correct
42 Correct 3 ms 12892 KB Output is correct
43 Correct 2 ms 12892 KB Output is correct
44 Correct 3 ms 12892 KB Output is correct
45 Correct 3 ms 12892 KB Output is correct
46 Correct 4 ms 12892 KB Output is correct
47 Correct 2 ms 12892 KB Output is correct
48 Correct 3 ms 12908 KB Output is correct
49 Correct 2 ms 12892 KB Output is correct
50 Correct 3 ms 12888 KB Output is correct
51 Correct 3 ms 12892 KB Output is correct
52 Correct 3 ms 12892 KB Output is correct
53 Correct 3 ms 12892 KB Output is correct
54 Correct 3 ms 12888 KB Output is correct
55 Correct 2 ms 12892 KB Output is correct
56 Correct 3 ms 12892 KB Output is correct
57 Correct 3 ms 12892 KB Output is correct
58 Correct 3 ms 12892 KB Output is correct
59 Correct 3 ms 12892 KB Output is correct
60 Correct 3 ms 12892 KB Output is correct
61 Correct 4 ms 12972 KB Output is correct
62 Correct 3 ms 12892 KB Output is correct
63 Correct 2 ms 12892 KB Output is correct
64 Correct 4 ms 12892 KB Output is correct
65 Correct 3 ms 12892 KB Output is correct
66 Correct 32 ms 12984 KB Output is correct
67 Correct 31 ms 12888 KB Output is correct
68 Correct 31 ms 12892 KB Output is correct
69 Incorrect 39 ms 14308 KB Output isn't correct
70 Halted 0 ms 0 KB -