Submission #427779

# Submission time Handle Problem Language Result Execution time Memory
427779 2021-06-14T22:23:30 Z amoo_safar IOI Fever (JOI21_fever) C++17
25 / 100
5000 ms 16796 KB
#include<bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()

using namespace std;

typedef pair<int, int> pii;

const int N = 1e5 + 10;
const int Inf = 1'000'000'010;

int n;
int x[N], y[N];
int dir[N];
pii vec[] = {{1, 0}, {0, -1}, {-1, 0}, {0, 1}};

set< pair<int, int> > st; // time, id
int mk[N];


int Collision(int a, int b){
	if(x[a] > x[b]) swap(a, b);
	if(x[a] == x[b]){
		if(y[a] > y[b]) swap(a, b);
		if(dir[a] == 3 && dir[b] == 1)
			return abs(y[a] - y[b]) / 2;
		return Inf;
	}

	if(y[a] == y[b]){
		// if(y[a] > y[b]) swap(a, b);
		if(dir[a] == 0 && dir[b] == 2)
			return abs(x[a] - x[b]) / 2;
		return Inf;
	}

	int dp_a = x[a] + y[a];
	int dp_b = x[b] + y[b];
	int dn_a = x[a] - y[a];
	int dn_b = x[b] - y[b];
	if(dp_a != dp_b && dn_a != dn_b)
		return Inf;
	int d = abs(x[a] - x[b]);
	if(dp_a == dp_b){
		if((dir[a] == 0 && dir[b] == 3) || (dir[a] == 1 && dir[b] == 2))
			return d;
		return Inf;
	} 
	if((dir[a] == 0 && dir[b] == 1) || (dir[a] == 3 && dir[b] == 2))
		return d;
	return Inf;
}

void Infect(int u, int tm){
	mk[u] = 1;
	for(int i = 0; i < n; i++){
		if(mk[i]) continue;
		int ds = Collision(u, i);
		if(ds >= tm && ds != Inf){
			st.insert({ds, i});
		}
	}
}

int Solve(){
	dir[0] = 0;
	for(int i = 1; i < n; i++){
		int X = abs(x[i] - x[0]);
		int Y = abs(y[i] - y[0]);
		if(X == Y){
			if(x[i] < x[0]) dir[i] = 0;
			else dir[i] = y[i] < y[0] ? 3 : 1;
		} else {
			if(X > Y){
				if( x[i] < x[0]) dir[i] = 0;
				else dir[i] = 2;
			} else {
				if( y[i] < y[0]) dir[i] = 3;
				else dir[i] = 1;
			}
		}
	}
	// cerr << "!! " ;
	// for(int i = 0; i < n; i++){
	// 	cerr << dir[i] << ' ';
	// }
	// cerr << '\n';
	memset(mk, 0, sizeof mk);
	st.insert({0, 0});
	while(!st.empty()){
		int fr = st.begin() -> S;
		int tm = st.begin() -> F;
		st.erase(st.begin());
		Infect(fr, tm);
	}


	int res = 0;
	for(int i = 0; i < n; i++)
		res += mk[i];
	return res;
}


int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> x[i] >> y[i];
		x[i] += x[i];
		y[i] += y[i];
	}
	
	int ans = 0;
	for(int _ = 0; _ < 4; _++){
		ans = max(ans, Solve());
		for(int i = 0; i < n; i++){
			int _x = x[i];
			x[i] = -y[i];
			y[i] = _x;
		}
		// break;
	}
	cout << ans << '\n';
	return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 716 KB Output is correct
2 Correct 1 ms 716 KB Output is correct
3 Correct 1 ms 716 KB Output is correct
4 Correct 1 ms 716 KB Output is correct
5 Correct 1 ms 716 KB Output is correct
6 Correct 1 ms 716 KB Output is correct
7 Correct 1 ms 716 KB Output is correct
8 Correct 1 ms 588 KB Output is correct
9 Correct 1 ms 716 KB Output is correct
10 Correct 1 ms 716 KB Output is correct
11 Correct 1 ms 588 KB Output is correct
12 Correct 1 ms 588 KB Output is correct
13 Correct 1 ms 716 KB Output is correct
14 Correct 1 ms 716 KB Output is correct
15 Correct 1 ms 716 KB Output is correct
16 Correct 1 ms 588 KB Output is correct
17 Correct 1 ms 716 KB Output is correct
18 Correct 1 ms 716 KB Output is correct
19 Correct 1 ms 588 KB Output is correct
20 Correct 1 ms 716 KB Output is correct
21 Correct 1 ms 588 KB Output is correct
22 Correct 1 ms 716 KB Output is correct
23 Correct 1 ms 716 KB Output is correct
24 Correct 1 ms 716 KB Output is correct
25 Correct 1 ms 716 KB Output is correct
26 Correct 1 ms 716 KB Output is correct
27 Correct 1 ms 588 KB Output is correct
28 Correct 1 ms 716 KB Output is correct
29 Correct 1 ms 716 KB Output is correct
30 Correct 1 ms 588 KB Output is correct
31 Correct 1 ms 716 KB Output is correct
32 Correct 1 ms 588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 716 KB Output is correct
2 Correct 1 ms 716 KB Output is correct
3 Correct 1 ms 716 KB Output is correct
4 Correct 1 ms 716 KB Output is correct
5 Correct 1 ms 716 KB Output is correct
6 Correct 1 ms 716 KB Output is correct
7 Correct 1 ms 716 KB Output is correct
8 Correct 1 ms 588 KB Output is correct
9 Correct 1 ms 716 KB Output is correct
10 Correct 1 ms 716 KB Output is correct
11 Correct 1 ms 588 KB Output is correct
12 Correct 1 ms 588 KB Output is correct
13 Correct 1 ms 716 KB Output is correct
14 Correct 1 ms 716 KB Output is correct
15 Correct 1 ms 716 KB Output is correct
16 Correct 1 ms 588 KB Output is correct
17 Correct 1 ms 716 KB Output is correct
18 Correct 1 ms 716 KB Output is correct
19 Correct 1 ms 588 KB Output is correct
20 Correct 1 ms 716 KB Output is correct
21 Correct 1 ms 588 KB Output is correct
22 Correct 1 ms 716 KB Output is correct
23 Correct 1 ms 716 KB Output is correct
24 Correct 1 ms 716 KB Output is correct
25 Correct 1 ms 716 KB Output is correct
26 Correct 1 ms 716 KB Output is correct
27 Correct 1 ms 588 KB Output is correct
28 Correct 1 ms 716 KB Output is correct
29 Correct 1 ms 716 KB Output is correct
30 Correct 1 ms 588 KB Output is correct
31 Correct 1 ms 716 KB Output is correct
32 Correct 1 ms 588 KB Output is correct
33 Correct 1 ms 588 KB Output is correct
34 Correct 1 ms 588 KB Output is correct
35 Correct 1 ms 588 KB Output is correct
36 Correct 1 ms 588 KB Output is correct
37 Correct 1 ms 716 KB Output is correct
38 Correct 1 ms 716 KB Output is correct
39 Correct 1 ms 716 KB Output is correct
40 Correct 1 ms 716 KB Output is correct
41 Correct 1 ms 716 KB Output is correct
42 Correct 2 ms 716 KB Output is correct
43 Correct 1 ms 588 KB Output is correct
44 Correct 1 ms 716 KB Output is correct
45 Correct 1 ms 716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 588 KB Output is correct
2 Correct 1 ms 588 KB Output is correct
3 Correct 1 ms 716 KB Output is correct
4 Correct 1 ms 588 KB Output is correct
5 Correct 1 ms 732 KB Output is correct
6 Correct 1 ms 716 KB Output is correct
7 Correct 1 ms 716 KB Output is correct
8 Correct 1 ms 716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 716 KB Output is correct
2 Correct 1 ms 716 KB Output is correct
3 Correct 1 ms 716 KB Output is correct
4 Correct 1 ms 716 KB Output is correct
5 Correct 1 ms 716 KB Output is correct
6 Correct 1 ms 716 KB Output is correct
7 Correct 1 ms 716 KB Output is correct
8 Correct 1 ms 588 KB Output is correct
9 Correct 1 ms 716 KB Output is correct
10 Correct 1 ms 716 KB Output is correct
11 Correct 1 ms 588 KB Output is correct
12 Correct 1 ms 588 KB Output is correct
13 Correct 1 ms 716 KB Output is correct
14 Correct 1 ms 716 KB Output is correct
15 Correct 1 ms 716 KB Output is correct
16 Correct 1 ms 588 KB Output is correct
17 Correct 1 ms 716 KB Output is correct
18 Correct 1 ms 716 KB Output is correct
19 Correct 1 ms 588 KB Output is correct
20 Correct 1 ms 716 KB Output is correct
21 Correct 1 ms 588 KB Output is correct
22 Correct 1 ms 716 KB Output is correct
23 Correct 1 ms 716 KB Output is correct
24 Correct 1 ms 716 KB Output is correct
25 Correct 1 ms 716 KB Output is correct
26 Correct 1 ms 716 KB Output is correct
27 Correct 1 ms 588 KB Output is correct
28 Correct 1 ms 716 KB Output is correct
29 Correct 1 ms 716 KB Output is correct
30 Correct 1 ms 588 KB Output is correct
31 Correct 1 ms 716 KB Output is correct
32 Correct 1 ms 588 KB Output is correct
33 Correct 1 ms 588 KB Output is correct
34 Correct 1 ms 588 KB Output is correct
35 Correct 1 ms 588 KB Output is correct
36 Correct 1 ms 588 KB Output is correct
37 Correct 1 ms 716 KB Output is correct
38 Correct 1 ms 716 KB Output is correct
39 Correct 1 ms 716 KB Output is correct
40 Correct 1 ms 716 KB Output is correct
41 Correct 1 ms 716 KB Output is correct
42 Correct 2 ms 716 KB Output is correct
43 Correct 1 ms 588 KB Output is correct
44 Correct 1 ms 716 KB Output is correct
45 Correct 1 ms 716 KB Output is correct
46 Correct 1 ms 588 KB Output is correct
47 Correct 1 ms 588 KB Output is correct
48 Correct 1 ms 716 KB Output is correct
49 Correct 1 ms 588 KB Output is correct
50 Correct 1 ms 732 KB Output is correct
51 Correct 1 ms 716 KB Output is correct
52 Correct 1 ms 716 KB Output is correct
53 Correct 1 ms 716 KB Output is correct
54 Correct 1 ms 588 KB Output is correct
55 Correct 1 ms 716 KB Output is correct
56 Correct 1 ms 716 KB Output is correct
57 Correct 1 ms 716 KB Output is correct
58 Correct 12 ms 804 KB Output is correct
59 Correct 2 ms 716 KB Output is correct
60 Correct 1 ms 716 KB Output is correct
61 Correct 1 ms 716 KB Output is correct
62 Correct 1 ms 756 KB Output is correct
63 Correct 1 ms 716 KB Output is correct
64 Correct 1 ms 588 KB Output is correct
65 Correct 2 ms 716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 716 KB Output is correct
2 Correct 1 ms 716 KB Output is correct
3 Correct 1 ms 716 KB Output is correct
4 Correct 1 ms 716 KB Output is correct
5 Correct 1 ms 716 KB Output is correct
6 Correct 1 ms 716 KB Output is correct
7 Correct 1 ms 716 KB Output is correct
8 Correct 1 ms 588 KB Output is correct
9 Correct 1 ms 716 KB Output is correct
10 Correct 1 ms 716 KB Output is correct
11 Correct 1 ms 588 KB Output is correct
12 Correct 1 ms 588 KB Output is correct
13 Correct 1 ms 716 KB Output is correct
14 Correct 1 ms 716 KB Output is correct
15 Correct 1 ms 716 KB Output is correct
16 Correct 1 ms 588 KB Output is correct
17 Correct 1 ms 716 KB Output is correct
18 Correct 1 ms 716 KB Output is correct
19 Correct 1 ms 588 KB Output is correct
20 Correct 1 ms 716 KB Output is correct
21 Correct 1 ms 588 KB Output is correct
22 Correct 1 ms 716 KB Output is correct
23 Correct 1 ms 716 KB Output is correct
24 Correct 1 ms 716 KB Output is correct
25 Correct 1 ms 716 KB Output is correct
26 Correct 1 ms 716 KB Output is correct
27 Correct 1 ms 588 KB Output is correct
28 Correct 1 ms 716 KB Output is correct
29 Correct 1 ms 716 KB Output is correct
30 Correct 1 ms 588 KB Output is correct
31 Correct 1 ms 716 KB Output is correct
32 Correct 1 ms 588 KB Output is correct
33 Correct 1 ms 588 KB Output is correct
34 Correct 1 ms 588 KB Output is correct
35 Correct 1 ms 588 KB Output is correct
36 Correct 1 ms 588 KB Output is correct
37 Correct 1 ms 716 KB Output is correct
38 Correct 1 ms 716 KB Output is correct
39 Correct 1 ms 716 KB Output is correct
40 Correct 1 ms 716 KB Output is correct
41 Correct 1 ms 716 KB Output is correct
42 Correct 2 ms 716 KB Output is correct
43 Correct 1 ms 588 KB Output is correct
44 Correct 1 ms 716 KB Output is correct
45 Correct 1 ms 716 KB Output is correct
46 Correct 1 ms 588 KB Output is correct
47 Correct 1 ms 588 KB Output is correct
48 Correct 1 ms 716 KB Output is correct
49 Correct 1 ms 588 KB Output is correct
50 Correct 1 ms 732 KB Output is correct
51 Correct 1 ms 716 KB Output is correct
52 Correct 1 ms 716 KB Output is correct
53 Correct 1 ms 716 KB Output is correct
54 Correct 1 ms 588 KB Output is correct
55 Correct 1 ms 716 KB Output is correct
56 Correct 1 ms 716 KB Output is correct
57 Correct 1 ms 716 KB Output is correct
58 Correct 12 ms 804 KB Output is correct
59 Correct 2 ms 716 KB Output is correct
60 Correct 1 ms 716 KB Output is correct
61 Correct 1 ms 716 KB Output is correct
62 Correct 1 ms 756 KB Output is correct
63 Correct 1 ms 716 KB Output is correct
64 Correct 1 ms 588 KB Output is correct
65 Correct 2 ms 716 KB Output is correct
66 Correct 1 ms 716 KB Output is correct
67 Correct 2 ms 716 KB Output is correct
68 Correct 2 ms 716 KB Output is correct
69 Correct 2036 ms 1696 KB Output is correct
70 Correct 218 ms 844 KB Output is correct
71 Correct 33 ms 720 KB Output is correct
72 Correct 2 ms 716 KB Output is correct
73 Correct 2 ms 716 KB Output is correct
74 Correct 117 ms 844 KB Output is correct
75 Execution timed out 5072 ms 16796 KB Time limit exceeded
76 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 716 KB Output is correct
2 Correct 1 ms 716 KB Output is correct
3 Correct 1 ms 716 KB Output is correct
4 Correct 1 ms 716 KB Output is correct
5 Correct 1 ms 716 KB Output is correct
6 Correct 1 ms 716 KB Output is correct
7 Correct 1 ms 716 KB Output is correct
8 Correct 1 ms 588 KB Output is correct
9 Correct 1 ms 716 KB Output is correct
10 Correct 1 ms 716 KB Output is correct
11 Correct 1 ms 588 KB Output is correct
12 Correct 1 ms 588 KB Output is correct
13 Correct 1 ms 716 KB Output is correct
14 Correct 1 ms 716 KB Output is correct
15 Correct 1 ms 716 KB Output is correct
16 Correct 1 ms 588 KB Output is correct
17 Correct 1 ms 716 KB Output is correct
18 Correct 1 ms 716 KB Output is correct
19 Correct 1 ms 588 KB Output is correct
20 Correct 1 ms 716 KB Output is correct
21 Correct 1 ms 588 KB Output is correct
22 Correct 1 ms 716 KB Output is correct
23 Correct 1 ms 716 KB Output is correct
24 Correct 1 ms 716 KB Output is correct
25 Correct 1 ms 716 KB Output is correct
26 Correct 1 ms 716 KB Output is correct
27 Correct 1 ms 588 KB Output is correct
28 Correct 1 ms 716 KB Output is correct
29 Correct 1 ms 716 KB Output is correct
30 Correct 1 ms 588 KB Output is correct
31 Correct 1 ms 716 KB Output is correct
32 Correct 1 ms 588 KB Output is correct
33 Correct 1 ms 588 KB Output is correct
34 Correct 1 ms 588 KB Output is correct
35 Correct 1 ms 588 KB Output is correct
36 Correct 1 ms 588 KB Output is correct
37 Correct 1 ms 716 KB Output is correct
38 Correct 1 ms 716 KB Output is correct
39 Correct 1 ms 716 KB Output is correct
40 Correct 1 ms 716 KB Output is correct
41 Correct 1 ms 716 KB Output is correct
42 Correct 2 ms 716 KB Output is correct
43 Correct 1 ms 588 KB Output is correct
44 Correct 1 ms 716 KB Output is correct
45 Correct 1 ms 716 KB Output is correct
46 Correct 1 ms 588 KB Output is correct
47 Correct 1 ms 588 KB Output is correct
48 Correct 1 ms 716 KB Output is correct
49 Correct 1 ms 588 KB Output is correct
50 Correct 1 ms 732 KB Output is correct
51 Correct 1 ms 716 KB Output is correct
52 Correct 1 ms 716 KB Output is correct
53 Correct 1 ms 716 KB Output is correct
54 Correct 1 ms 588 KB Output is correct
55 Correct 1 ms 716 KB Output is correct
56 Correct 1 ms 716 KB Output is correct
57 Correct 1 ms 716 KB Output is correct
58 Correct 12 ms 804 KB Output is correct
59 Correct 2 ms 716 KB Output is correct
60 Correct 1 ms 716 KB Output is correct
61 Correct 1 ms 716 KB Output is correct
62 Correct 1 ms 756 KB Output is correct
63 Correct 1 ms 716 KB Output is correct
64 Correct 1 ms 588 KB Output is correct
65 Correct 2 ms 716 KB Output is correct
66 Correct 25 ms 1608 KB Output is correct
67 Correct 32 ms 1796 KB Output is correct
68 Correct 32 ms 1784 KB Output is correct
69 Execution timed out 5053 ms 6552 KB Time limit exceeded
70 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 716 KB Output is correct
2 Correct 1 ms 716 KB Output is correct
3 Correct 1 ms 716 KB Output is correct
4 Correct 1 ms 716 KB Output is correct
5 Correct 1 ms 716 KB Output is correct
6 Correct 1 ms 716 KB Output is correct
7 Correct 1 ms 716 KB Output is correct
8 Correct 1 ms 588 KB Output is correct
9 Correct 1 ms 716 KB Output is correct
10 Correct 1 ms 716 KB Output is correct
11 Correct 1 ms 588 KB Output is correct
12 Correct 1 ms 588 KB Output is correct
13 Correct 1 ms 716 KB Output is correct
14 Correct 1 ms 716 KB Output is correct
15 Correct 1 ms 716 KB Output is correct
16 Correct 1 ms 588 KB Output is correct
17 Correct 1 ms 716 KB Output is correct
18 Correct 1 ms 716 KB Output is correct
19 Correct 1 ms 588 KB Output is correct
20 Correct 1 ms 716 KB Output is correct
21 Correct 1 ms 588 KB Output is correct
22 Correct 1 ms 716 KB Output is correct
23 Correct 1 ms 716 KB Output is correct
24 Correct 1 ms 716 KB Output is correct
25 Correct 1 ms 716 KB Output is correct
26 Correct 1 ms 716 KB Output is correct
27 Correct 1 ms 588 KB Output is correct
28 Correct 1 ms 716 KB Output is correct
29 Correct 1 ms 716 KB Output is correct
30 Correct 1 ms 588 KB Output is correct
31 Correct 1 ms 716 KB Output is correct
32 Correct 1 ms 588 KB Output is correct
33 Correct 1 ms 588 KB Output is correct
34 Correct 1 ms 588 KB Output is correct
35 Correct 1 ms 588 KB Output is correct
36 Correct 1 ms 588 KB Output is correct
37 Correct 1 ms 716 KB Output is correct
38 Correct 1 ms 716 KB Output is correct
39 Correct 1 ms 716 KB Output is correct
40 Correct 1 ms 716 KB Output is correct
41 Correct 1 ms 716 KB Output is correct
42 Correct 2 ms 716 KB Output is correct
43 Correct 1 ms 588 KB Output is correct
44 Correct 1 ms 716 KB Output is correct
45 Correct 1 ms 716 KB Output is correct
46 Correct 1 ms 588 KB Output is correct
47 Correct 1 ms 588 KB Output is correct
48 Correct 1 ms 716 KB Output is correct
49 Correct 1 ms 588 KB Output is correct
50 Correct 1 ms 732 KB Output is correct
51 Correct 1 ms 716 KB Output is correct
52 Correct 1 ms 716 KB Output is correct
53 Correct 1 ms 716 KB Output is correct
54 Correct 1 ms 588 KB Output is correct
55 Correct 1 ms 716 KB Output is correct
56 Correct 1 ms 716 KB Output is correct
57 Correct 1 ms 716 KB Output is correct
58 Correct 12 ms 804 KB Output is correct
59 Correct 2 ms 716 KB Output is correct
60 Correct 1 ms 716 KB Output is correct
61 Correct 1 ms 716 KB Output is correct
62 Correct 1 ms 756 KB Output is correct
63 Correct 1 ms 716 KB Output is correct
64 Correct 1 ms 588 KB Output is correct
65 Correct 2 ms 716 KB Output is correct
66 Correct 1 ms 716 KB Output is correct
67 Correct 2 ms 716 KB Output is correct
68 Correct 2 ms 716 KB Output is correct
69 Correct 2036 ms 1696 KB Output is correct
70 Correct 218 ms 844 KB Output is correct
71 Correct 33 ms 720 KB Output is correct
72 Correct 2 ms 716 KB Output is correct
73 Correct 2 ms 716 KB Output is correct
74 Correct 117 ms 844 KB Output is correct
75 Execution timed out 5072 ms 16796 KB Time limit exceeded
76 Halted 0 ms 0 KB -