Submission #427785

# Submission time Handle Problem Language Result Execution time Memory
427785 2021-06-14T22:36:39 Z amoo_safar IOI Fever (JOI21_fever) C++17
0 / 100
2 ms 1100 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;
}

int dis[N];

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 && dis[i] > ds){
			st.erase({dis[i], i});
			dis[i] = ds;
			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);
	memset(dis, 31, sizeof dis);
	
	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 1100 KB Output is correct
2 Correct 1 ms 1100 KB Output is correct
3 Correct 1 ms 1052 KB Output is correct
4 Correct 1 ms 1100 KB Output is correct
5 Correct 1 ms 1100 KB Output is correct
6 Correct 1 ms 1100 KB Output is correct
7 Correct 1 ms 1100 KB Output is correct
8 Correct 2 ms 1100 KB Output is correct
9 Correct 1 ms 1100 KB Output is correct
10 Correct 1 ms 1100 KB Output is correct
11 Correct 1 ms 1100 KB Output is correct
12 Correct 1 ms 1100 KB Output is correct
13 Correct 1 ms 1100 KB Output is correct
14 Correct 1 ms 1100 KB Output is correct
15 Correct 1 ms 1100 KB Output is correct
16 Correct 1 ms 1100 KB Output is correct
17 Correct 1 ms 1100 KB Output is correct
18 Correct 1 ms 1100 KB Output is correct
19 Correct 1 ms 1100 KB Output is correct
20 Correct 1 ms 1100 KB Output is correct
21 Correct 1 ms 1100 KB Output is correct
22 Correct 1 ms 1100 KB Output is correct
23 Correct 1 ms 1100 KB Output is correct
24 Correct 1 ms 1100 KB Output is correct
25 Correct 1 ms 1100 KB Output is correct
26 Correct 1 ms 1100 KB Output is correct
27 Correct 1 ms 1100 KB Output is correct
28 Correct 1 ms 1100 KB Output is correct
29 Correct 1 ms 1100 KB Output is correct
30 Incorrect 1 ms 1100 KB Output isn't correct
31 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1100 KB Output is correct
2 Correct 1 ms 1100 KB Output is correct
3 Correct 1 ms 1052 KB Output is correct
4 Correct 1 ms 1100 KB Output is correct
5 Correct 1 ms 1100 KB Output is correct
6 Correct 1 ms 1100 KB Output is correct
7 Correct 1 ms 1100 KB Output is correct
8 Correct 2 ms 1100 KB Output is correct
9 Correct 1 ms 1100 KB Output is correct
10 Correct 1 ms 1100 KB Output is correct
11 Correct 1 ms 1100 KB Output is correct
12 Correct 1 ms 1100 KB Output is correct
13 Correct 1 ms 1100 KB Output is correct
14 Correct 1 ms 1100 KB Output is correct
15 Correct 1 ms 1100 KB Output is correct
16 Correct 1 ms 1100 KB Output is correct
17 Correct 1 ms 1100 KB Output is correct
18 Correct 1 ms 1100 KB Output is correct
19 Correct 1 ms 1100 KB Output is correct
20 Correct 1 ms 1100 KB Output is correct
21 Correct 1 ms 1100 KB Output is correct
22 Correct 1 ms 1100 KB Output is correct
23 Correct 1 ms 1100 KB Output is correct
24 Correct 1 ms 1100 KB Output is correct
25 Correct 1 ms 1100 KB Output is correct
26 Correct 1 ms 1100 KB Output is correct
27 Correct 1 ms 1100 KB Output is correct
28 Correct 1 ms 1100 KB Output is correct
29 Correct 1 ms 1100 KB Output is correct
30 Incorrect 1 ms 1100 KB Output isn't correct
31 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1100 KB Output is correct
2 Correct 1 ms 1036 KB Output is correct
3 Correct 1 ms 1100 KB Output is correct
4 Correct 1 ms 1100 KB Output is correct
5 Correct 1 ms 1100 KB Output is correct
6 Correct 2 ms 1100 KB Output is correct
7 Correct 1 ms 1100 KB Output is correct
8 Incorrect 1 ms 1100 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1100 KB Output is correct
2 Correct 1 ms 1100 KB Output is correct
3 Correct 1 ms 1052 KB Output is correct
4 Correct 1 ms 1100 KB Output is correct
5 Correct 1 ms 1100 KB Output is correct
6 Correct 1 ms 1100 KB Output is correct
7 Correct 1 ms 1100 KB Output is correct
8 Correct 2 ms 1100 KB Output is correct
9 Correct 1 ms 1100 KB Output is correct
10 Correct 1 ms 1100 KB Output is correct
11 Correct 1 ms 1100 KB Output is correct
12 Correct 1 ms 1100 KB Output is correct
13 Correct 1 ms 1100 KB Output is correct
14 Correct 1 ms 1100 KB Output is correct
15 Correct 1 ms 1100 KB Output is correct
16 Correct 1 ms 1100 KB Output is correct
17 Correct 1 ms 1100 KB Output is correct
18 Correct 1 ms 1100 KB Output is correct
19 Correct 1 ms 1100 KB Output is correct
20 Correct 1 ms 1100 KB Output is correct
21 Correct 1 ms 1100 KB Output is correct
22 Correct 1 ms 1100 KB Output is correct
23 Correct 1 ms 1100 KB Output is correct
24 Correct 1 ms 1100 KB Output is correct
25 Correct 1 ms 1100 KB Output is correct
26 Correct 1 ms 1100 KB Output is correct
27 Correct 1 ms 1100 KB Output is correct
28 Correct 1 ms 1100 KB Output is correct
29 Correct 1 ms 1100 KB Output is correct
30 Incorrect 1 ms 1100 KB Output isn't correct
31 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1100 KB Output is correct
2 Correct 1 ms 1100 KB Output is correct
3 Correct 1 ms 1052 KB Output is correct
4 Correct 1 ms 1100 KB Output is correct
5 Correct 1 ms 1100 KB Output is correct
6 Correct 1 ms 1100 KB Output is correct
7 Correct 1 ms 1100 KB Output is correct
8 Correct 2 ms 1100 KB Output is correct
9 Correct 1 ms 1100 KB Output is correct
10 Correct 1 ms 1100 KB Output is correct
11 Correct 1 ms 1100 KB Output is correct
12 Correct 1 ms 1100 KB Output is correct
13 Correct 1 ms 1100 KB Output is correct
14 Correct 1 ms 1100 KB Output is correct
15 Correct 1 ms 1100 KB Output is correct
16 Correct 1 ms 1100 KB Output is correct
17 Correct 1 ms 1100 KB Output is correct
18 Correct 1 ms 1100 KB Output is correct
19 Correct 1 ms 1100 KB Output is correct
20 Correct 1 ms 1100 KB Output is correct
21 Correct 1 ms 1100 KB Output is correct
22 Correct 1 ms 1100 KB Output is correct
23 Correct 1 ms 1100 KB Output is correct
24 Correct 1 ms 1100 KB Output is correct
25 Correct 1 ms 1100 KB Output is correct
26 Correct 1 ms 1100 KB Output is correct
27 Correct 1 ms 1100 KB Output is correct
28 Correct 1 ms 1100 KB Output is correct
29 Correct 1 ms 1100 KB Output is correct
30 Incorrect 1 ms 1100 KB Output isn't correct
31 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1100 KB Output is correct
2 Correct 1 ms 1100 KB Output is correct
3 Correct 1 ms 1052 KB Output is correct
4 Correct 1 ms 1100 KB Output is correct
5 Correct 1 ms 1100 KB Output is correct
6 Correct 1 ms 1100 KB Output is correct
7 Correct 1 ms 1100 KB Output is correct
8 Correct 2 ms 1100 KB Output is correct
9 Correct 1 ms 1100 KB Output is correct
10 Correct 1 ms 1100 KB Output is correct
11 Correct 1 ms 1100 KB Output is correct
12 Correct 1 ms 1100 KB Output is correct
13 Correct 1 ms 1100 KB Output is correct
14 Correct 1 ms 1100 KB Output is correct
15 Correct 1 ms 1100 KB Output is correct
16 Correct 1 ms 1100 KB Output is correct
17 Correct 1 ms 1100 KB Output is correct
18 Correct 1 ms 1100 KB Output is correct
19 Correct 1 ms 1100 KB Output is correct
20 Correct 1 ms 1100 KB Output is correct
21 Correct 1 ms 1100 KB Output is correct
22 Correct 1 ms 1100 KB Output is correct
23 Correct 1 ms 1100 KB Output is correct
24 Correct 1 ms 1100 KB Output is correct
25 Correct 1 ms 1100 KB Output is correct
26 Correct 1 ms 1100 KB Output is correct
27 Correct 1 ms 1100 KB Output is correct
28 Correct 1 ms 1100 KB Output is correct
29 Correct 1 ms 1100 KB Output is correct
30 Incorrect 1 ms 1100 KB Output isn't correct
31 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1100 KB Output is correct
2 Correct 1 ms 1100 KB Output is correct
3 Correct 1 ms 1052 KB Output is correct
4 Correct 1 ms 1100 KB Output is correct
5 Correct 1 ms 1100 KB Output is correct
6 Correct 1 ms 1100 KB Output is correct
7 Correct 1 ms 1100 KB Output is correct
8 Correct 2 ms 1100 KB Output is correct
9 Correct 1 ms 1100 KB Output is correct
10 Correct 1 ms 1100 KB Output is correct
11 Correct 1 ms 1100 KB Output is correct
12 Correct 1 ms 1100 KB Output is correct
13 Correct 1 ms 1100 KB Output is correct
14 Correct 1 ms 1100 KB Output is correct
15 Correct 1 ms 1100 KB Output is correct
16 Correct 1 ms 1100 KB Output is correct
17 Correct 1 ms 1100 KB Output is correct
18 Correct 1 ms 1100 KB Output is correct
19 Correct 1 ms 1100 KB Output is correct
20 Correct 1 ms 1100 KB Output is correct
21 Correct 1 ms 1100 KB Output is correct
22 Correct 1 ms 1100 KB Output is correct
23 Correct 1 ms 1100 KB Output is correct
24 Correct 1 ms 1100 KB Output is correct
25 Correct 1 ms 1100 KB Output is correct
26 Correct 1 ms 1100 KB Output is correct
27 Correct 1 ms 1100 KB Output is correct
28 Correct 1 ms 1100 KB Output is correct
29 Correct 1 ms 1100 KB Output is correct
30 Incorrect 1 ms 1100 KB Output isn't correct
31 Halted 0 ms 0 KB -