답안 #426201

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
426201 2021-06-13T15:10:53 Z 8e7 IOI 바이러스 (JOI21_fever) C++14
13 / 100
146 ms 324 KB
//Challenge: Accepted
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
void debug() {cout << endl;}
template<class T, class ... U> void debug(T a, U ... b){ cout << a << " ";debug(b ...);};
template<class T> void pary(T l, T r) {
	while (l != r) cout << *l << " ", l++;
	cout << endl;
}
#define ll long long
#define maxn 100005
#define pii pair<int, int>
#define ff first
#define ss second
#define io ios_base::sync_with_stdio(0);cin.tie(0);
//using namespace __gnu_pbds;
pii a[maxn];
int dir[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
int val[maxn], type[maxn];
int solve(int n) {
	//pary(val, val + n);
	bool in[n];
	for (int i = 0;i < n;i++) in[i] = 0;
	in[0] = 1;
	vector<pair<ll, pii>> ev;
	for (int i = 0;i < n;i++) {
		for (int j = i + 1;j < n;j++) {
			if (val[i] % 2 != val[j] % 2) {
				pii inter;
				ll dx = 0, dy = 0;
				if (val[i] % 2) {
					inter = {a[i].ff, a[j].ss};
					dy = (a[j].ss - a[i].ss) / dir[val[i]][1];
					dx = (a[i].ff - a[j].ff) / dir[val[j]][0];
				} else {
					inter = {a[j].ff, a[i].ss};
					dy = (a[i].ss - a[j].ss) / dir[val[j]][1];
					dx = (a[j].ff - a[i].ff) / dir[val[i]][0];
				}
				if (dx > 0 && dy > 0 && dx == dy) {
					ev.push_back(make_pair(dx, make_pair(i,j)));
				}	
			}
		}
	}
	sort(ev.begin(), ev.end());
	for (auto i:ev) {
		if (in[i.ss.ff] || in[i.ss.ss]) {
			in[i.ss.ff] = in[i.ss.ss] = 1;
		}
	}
	int cnt = 0;
	for (int i = 0;i < n;i++) cnt += in[i] ? 1 : 0;
	return cnt;
}
int main() {
	io
	int n;
	cin >> n;
	for (int i = 0;i < n;i++) {
		cin >> a[i].ff >> a[i].ss;
	}
	for (int i = 1;i < n;i++) {
		if (a[i].ff < a[0].ff) {
			if (a[i].ss < a[0].ss) type[i] = 0;
			else type[i] = 3;
		} else {
			if (a[i].ss < a[0].ss) type[i] = 1;
			else type[i] = 2;
		}
	}
	int ans = 1;
	for (int i = 0;i < (1<<(n + 1));i++) {
		val[0] = i & 3;
		for (int j = 1;j < n;j++) {
			val[j] = (type[j] + ((i & (1<<(j + 1))) ? 1 : 0)) % 4;
		}
		ans = max(ans, solve(n));
	}
	cout << ans << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 66 ms 304 KB Output is correct
34 Correct 80 ms 204 KB Output is correct
35 Correct 60 ms 300 KB Output is correct
36 Correct 90 ms 204 KB Output is correct
37 Correct 60 ms 204 KB Output is correct
38 Correct 146 ms 204 KB Output is correct
39 Correct 125 ms 204 KB Output is correct
40 Correct 105 ms 204 KB Output is correct
41 Correct 92 ms 304 KB Output is correct
42 Correct 85 ms 204 KB Output is correct
43 Correct 94 ms 304 KB Output is correct
44 Correct 81 ms 324 KB Output is correct
45 Correct 86 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Incorrect 1 ms 204 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 66 ms 304 KB Output is correct
34 Correct 80 ms 204 KB Output is correct
35 Correct 60 ms 300 KB Output is correct
36 Correct 90 ms 204 KB Output is correct
37 Correct 60 ms 204 KB Output is correct
38 Correct 146 ms 204 KB Output is correct
39 Correct 125 ms 204 KB Output is correct
40 Correct 105 ms 204 KB Output is correct
41 Correct 92 ms 304 KB Output is correct
42 Correct 85 ms 204 KB Output is correct
43 Correct 94 ms 304 KB Output is correct
44 Correct 81 ms 324 KB Output is correct
45 Correct 86 ms 204 KB Output is correct
46 Correct 1 ms 204 KB Output is correct
47 Correct 1 ms 204 KB Output is correct
48 Correct 1 ms 204 KB Output is correct
49 Correct 1 ms 204 KB Output is correct
50 Correct 1 ms 204 KB Output is correct
51 Incorrect 1 ms 204 KB Output isn't correct
52 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 66 ms 304 KB Output is correct
34 Correct 80 ms 204 KB Output is correct
35 Correct 60 ms 300 KB Output is correct
36 Correct 90 ms 204 KB Output is correct
37 Correct 60 ms 204 KB Output is correct
38 Correct 146 ms 204 KB Output is correct
39 Correct 125 ms 204 KB Output is correct
40 Correct 105 ms 204 KB Output is correct
41 Correct 92 ms 304 KB Output is correct
42 Correct 85 ms 204 KB Output is correct
43 Correct 94 ms 304 KB Output is correct
44 Correct 81 ms 324 KB Output is correct
45 Correct 86 ms 204 KB Output is correct
46 Correct 1 ms 204 KB Output is correct
47 Correct 1 ms 204 KB Output is correct
48 Correct 1 ms 204 KB Output is correct
49 Correct 1 ms 204 KB Output is correct
50 Correct 1 ms 204 KB Output is correct
51 Incorrect 1 ms 204 KB Output isn't correct
52 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 66 ms 304 KB Output is correct
34 Correct 80 ms 204 KB Output is correct
35 Correct 60 ms 300 KB Output is correct
36 Correct 90 ms 204 KB Output is correct
37 Correct 60 ms 204 KB Output is correct
38 Correct 146 ms 204 KB Output is correct
39 Correct 125 ms 204 KB Output is correct
40 Correct 105 ms 204 KB Output is correct
41 Correct 92 ms 304 KB Output is correct
42 Correct 85 ms 204 KB Output is correct
43 Correct 94 ms 304 KB Output is correct
44 Correct 81 ms 324 KB Output is correct
45 Correct 86 ms 204 KB Output is correct
46 Correct 1 ms 204 KB Output is correct
47 Correct 1 ms 204 KB Output is correct
48 Correct 1 ms 204 KB Output is correct
49 Correct 1 ms 204 KB Output is correct
50 Correct 1 ms 204 KB Output is correct
51 Incorrect 1 ms 204 KB Output isn't correct
52 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 66 ms 304 KB Output is correct
34 Correct 80 ms 204 KB Output is correct
35 Correct 60 ms 300 KB Output is correct
36 Correct 90 ms 204 KB Output is correct
37 Correct 60 ms 204 KB Output is correct
38 Correct 146 ms 204 KB Output is correct
39 Correct 125 ms 204 KB Output is correct
40 Correct 105 ms 204 KB Output is correct
41 Correct 92 ms 304 KB Output is correct
42 Correct 85 ms 204 KB Output is correct
43 Correct 94 ms 304 KB Output is correct
44 Correct 81 ms 324 KB Output is correct
45 Correct 86 ms 204 KB Output is correct
46 Correct 1 ms 204 KB Output is correct
47 Correct 1 ms 204 KB Output is correct
48 Correct 1 ms 204 KB Output is correct
49 Correct 1 ms 204 KB Output is correct
50 Correct 1 ms 204 KB Output is correct
51 Incorrect 1 ms 204 KB Output isn't correct
52 Halted 0 ms 0 KB -