답안 #427778

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
427778 2021-06-14T22:20:04 Z amoo_safar IOI 바이러스 (JOI21_fever) C++17
25 / 100
5000 ms 7620 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);

	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];
	
	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;
}

# 결과 실행 시간 메모리 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 716 KB Output is correct
9 Correct 1 ms 716 KB Output is correct
10 Correct 1 ms 768 KB Output is correct
11 Correct 1 ms 712 KB Output is correct
12 Correct 1 ms 716 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 716 KB Output is correct
17 Correct 1 ms 704 KB Output is correct
18 Correct 1 ms 716 KB Output is correct
19 Correct 1 ms 712 KB Output is correct
20 Correct 1 ms 716 KB Output is correct
21 Correct 1 ms 716 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 716 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 716 KB Output is correct
31 Correct 1 ms 708 KB Output is correct
32 Correct 1 ms 808 KB Output is correct
# 결과 실행 시간 메모리 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 716 KB Output is correct
9 Correct 1 ms 716 KB Output is correct
10 Correct 1 ms 768 KB Output is correct
11 Correct 1 ms 712 KB Output is correct
12 Correct 1 ms 716 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 716 KB Output is correct
17 Correct 1 ms 704 KB Output is correct
18 Correct 1 ms 716 KB Output is correct
19 Correct 1 ms 712 KB Output is correct
20 Correct 1 ms 716 KB Output is correct
21 Correct 1 ms 716 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 716 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 716 KB Output is correct
31 Correct 1 ms 708 KB Output is correct
32 Correct 1 ms 808 KB Output is correct
33 Correct 1 ms 716 KB Output is correct
34 Correct 1 ms 716 KB Output is correct
35 Correct 1 ms 716 KB Output is correct
36 Correct 1 ms 716 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 1 ms 712 KB Output is correct
43 Correct 1 ms 716 KB Output is correct
44 Correct 1 ms 716 KB Output is correct
45 Correct 1 ms 716 KB Output is correct
# 결과 실행 시간 메모리 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 712 KB Output is correct
7 Correct 1 ms 716 KB Output is correct
8 Correct 1 ms 716 KB Output is correct
# 결과 실행 시간 메모리 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 716 KB Output is correct
9 Correct 1 ms 716 KB Output is correct
10 Correct 1 ms 768 KB Output is correct
11 Correct 1 ms 712 KB Output is correct
12 Correct 1 ms 716 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 716 KB Output is correct
17 Correct 1 ms 704 KB Output is correct
18 Correct 1 ms 716 KB Output is correct
19 Correct 1 ms 712 KB Output is correct
20 Correct 1 ms 716 KB Output is correct
21 Correct 1 ms 716 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 716 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 716 KB Output is correct
31 Correct 1 ms 708 KB Output is correct
32 Correct 1 ms 808 KB Output is correct
33 Correct 1 ms 716 KB Output is correct
34 Correct 1 ms 716 KB Output is correct
35 Correct 1 ms 716 KB Output is correct
36 Correct 1 ms 716 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 1 ms 712 KB Output is correct
43 Correct 1 ms 716 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 716 KB Output is correct
47 Correct 1 ms 716 KB Output is correct
48 Correct 1 ms 716 KB Output is correct
49 Correct 1 ms 716 KB Output is correct
50 Correct 1 ms 716 KB Output is correct
51 Correct 1 ms 712 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 716 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 812 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 716 KB Output is correct
63 Correct 1 ms 716 KB Output is correct
64 Correct 1 ms 716 KB Output is correct
65 Correct 1 ms 716 KB Output is correct
# 결과 실행 시간 메모리 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 716 KB Output is correct
9 Correct 1 ms 716 KB Output is correct
10 Correct 1 ms 768 KB Output is correct
11 Correct 1 ms 712 KB Output is correct
12 Correct 1 ms 716 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 716 KB Output is correct
17 Correct 1 ms 704 KB Output is correct
18 Correct 1 ms 716 KB Output is correct
19 Correct 1 ms 712 KB Output is correct
20 Correct 1 ms 716 KB Output is correct
21 Correct 1 ms 716 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 716 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 716 KB Output is correct
31 Correct 1 ms 708 KB Output is correct
32 Correct 1 ms 808 KB Output is correct
33 Correct 1 ms 716 KB Output is correct
34 Correct 1 ms 716 KB Output is correct
35 Correct 1 ms 716 KB Output is correct
36 Correct 1 ms 716 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 1 ms 712 KB Output is correct
43 Correct 1 ms 716 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 716 KB Output is correct
47 Correct 1 ms 716 KB Output is correct
48 Correct 1 ms 716 KB Output is correct
49 Correct 1 ms 716 KB Output is correct
50 Correct 1 ms 716 KB Output is correct
51 Correct 1 ms 712 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 716 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 812 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 716 KB Output is correct
63 Correct 1 ms 716 KB Output is correct
64 Correct 1 ms 716 KB Output is correct
65 Correct 1 ms 716 KB Output is correct
66 Correct 2 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 Incorrect 851 ms 984 KB Output isn't correct
70 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 716 KB Output is correct
9 Correct 1 ms 716 KB Output is correct
10 Correct 1 ms 768 KB Output is correct
11 Correct 1 ms 712 KB Output is correct
12 Correct 1 ms 716 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 716 KB Output is correct
17 Correct 1 ms 704 KB Output is correct
18 Correct 1 ms 716 KB Output is correct
19 Correct 1 ms 712 KB Output is correct
20 Correct 1 ms 716 KB Output is correct
21 Correct 1 ms 716 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 716 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 716 KB Output is correct
31 Correct 1 ms 708 KB Output is correct
32 Correct 1 ms 808 KB Output is correct
33 Correct 1 ms 716 KB Output is correct
34 Correct 1 ms 716 KB Output is correct
35 Correct 1 ms 716 KB Output is correct
36 Correct 1 ms 716 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 1 ms 712 KB Output is correct
43 Correct 1 ms 716 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 716 KB Output is correct
47 Correct 1 ms 716 KB Output is correct
48 Correct 1 ms 716 KB Output is correct
49 Correct 1 ms 716 KB Output is correct
50 Correct 1 ms 716 KB Output is correct
51 Correct 1 ms 712 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 716 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 812 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 716 KB Output is correct
63 Correct 1 ms 716 KB Output is correct
64 Correct 1 ms 716 KB Output is correct
65 Correct 1 ms 716 KB Output is correct
66 Correct 30 ms 2452 KB Output is correct
67 Correct 39 ms 3004 KB Output is correct
68 Correct 34 ms 3708 KB Output is correct
69 Execution timed out 5049 ms 7620 KB Time limit exceeded
70 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 716 KB Output is correct
9 Correct 1 ms 716 KB Output is correct
10 Correct 1 ms 768 KB Output is correct
11 Correct 1 ms 712 KB Output is correct
12 Correct 1 ms 716 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 716 KB Output is correct
17 Correct 1 ms 704 KB Output is correct
18 Correct 1 ms 716 KB Output is correct
19 Correct 1 ms 712 KB Output is correct
20 Correct 1 ms 716 KB Output is correct
21 Correct 1 ms 716 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 716 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 716 KB Output is correct
31 Correct 1 ms 708 KB Output is correct
32 Correct 1 ms 808 KB Output is correct
33 Correct 1 ms 716 KB Output is correct
34 Correct 1 ms 716 KB Output is correct
35 Correct 1 ms 716 KB Output is correct
36 Correct 1 ms 716 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 1 ms 712 KB Output is correct
43 Correct 1 ms 716 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 716 KB Output is correct
47 Correct 1 ms 716 KB Output is correct
48 Correct 1 ms 716 KB Output is correct
49 Correct 1 ms 716 KB Output is correct
50 Correct 1 ms 716 KB Output is correct
51 Correct 1 ms 712 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 716 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 812 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 716 KB Output is correct
63 Correct 1 ms 716 KB Output is correct
64 Correct 1 ms 716 KB Output is correct
65 Correct 1 ms 716 KB Output is correct
66 Correct 2 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 Incorrect 851 ms 984 KB Output isn't correct
70 Halted 0 ms 0 KB -