답안 #525001

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
525001 2022-02-10T12:51:11 Z blue IOI 바이러스 (JOI21_fever) C++17
25 / 100
5000 ms 12284 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
using namespace std;

using mii = map<int, int>;
using vi = vector<int>;
using pii = pair<int, int>;
using vpii = vector<pii>;
#define sz(x) int(x.size())

const int dr = 0;
const int dt = 1;
const int dl = 2;
const int dd = 3;

const int INF = 2'000'000'001;


struct event
{
	int t;
	int i;
	int j;
};

vpii delta{{+1, 0}, {0, +1}, {-1, 0}, {0, -1}};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);


	int N;
	cin >> N;

	int* X = new int[N];
	int* Y = new int[N];
	for(int i = 0; i < N; i++) 
	{
		cin >> X[i] >> Y[i];
		X[i] *= 2;
		Y[i] *= 2;
	}

	int res = 1;

	for(int i = N-1; i >= 0; i--)
	{
		X[i] -= X[0];
		Y[i] -= Y[0];
	}

	for(int t = 0; t < 4; t++)
	{
		cerr << "\n\n\n\n\n\n\n\n\n\n t = " << t << '\n';		

		vi dir(N);
		dir[0] = dt;


		for(int i = 1; i < N; i++)
		{
			cerr << i << " <> " << X[i] << ' ' << Y[i] << " : " << int(Y[i] > 0) << ' ' << int(X[i]+Y[i]>0) << ' ' << int(Y[i]-X[i]>0) << '\n';
			if(Y[i] > 0 && X[i]+Y[i] > 0 && Y[i]-X[i] > 0)
				dir[i] = dd;
			else if(Y[i] < 0 && X[i]+Y[i] <= 0 && Y[i]-X[i] <= 0)
				dir[i] = dt;
			else if(X[i] < 0)
				dir[i] = dr;
			else if(X[i] > 0)
				dir[i] = dl;

			cerr << dir[i] << ' ' << dd << '\n';
		}




		cerr << "\n\n\n";
		for(int i = 0; i < N; i++) cerr << X[i] << ' ' << Y[i] << ' ' << dir[i] << '\n';



		vector<event> E;




		for(int i = 0; i < N; i++)
		{
			for(int j = i+1; j < N; j++)
			{
				int t = -1;
				if(X[i] == X[j])
					t = abs(Y[j] - Y[i])/2;
				else if(Y[i] == Y[j])
					t = abs(X[j] - X[i])/2;
				else
					t = abs(X[i] - X[j]);

				cerr << "t = " << t << '\n';

				pii di = delta[dir[i]];
				pii dj = delta[dir[j]];

				di.first *= t;
				di.second *= t;

				dj.first *= t;
				dj.second *= t;


				cerr << di.first << ' ' << di.second << ' ' << dj.first << ' ' << dj.second << '\n';
				cerr << X[i] << ' ' << Y[i] << "  " << X[j] << ' ' << Y[j] << '\n';

				di.first += X[i];
				di.second += Y[i];

				dj.first += X[j];
				dj.second += Y[j];

				cerr << di.first << ' ' << di.second << ' ' << dj.first << ' ' << dj.second << '\n';

 
				if(di == dj && t != -1)
				{
					E.push_back({t, i, j});
				}
			}
		}
		cerr << "events size = " << sz(E) << '\n';

		vi infected(N, 0);
		infected[0] = 1;

		sort(E.begin(), E.end(), [] (event u, event v)
		{
			return u.t < v.t;
		});

		for(event e : E)
		{
			infected[e.i] = infected[e.j] = (infected[e.i] || infected[e.j]);
		}

		int curr = 0;
		for(int i = 0; i < N; i++) curr += infected[i];

		res = max(res, curr);




	

		for(int i = 0; i < N; i++)
		{
			int newX = -Y[i], newY = X[i];
			X[i] = newX;
			Y[i] = newY;
		}
	}

	cout << res << '\n';
}
# 결과 실행 시간 메모리 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 2 ms 204 KB Output is correct
8 Correct 2 ms 204 KB Output is correct
9 Correct 2 ms 204 KB Output is correct
10 Correct 2 ms 204 KB Output is correct
11 Correct 2 ms 204 KB Output is correct
12 Correct 2 ms 204 KB Output is correct
13 Correct 3 ms 204 KB Output is correct
14 Correct 3 ms 204 KB Output is correct
15 Correct 3 ms 204 KB Output is correct
16 Correct 4 ms 204 KB Output is correct
17 Correct 4 ms 204 KB Output is correct
18 Correct 4 ms 204 KB Output is correct
19 Correct 3 ms 204 KB Output is correct
20 Correct 4 ms 312 KB Output is correct
21 Correct 5 ms 204 KB Output is correct
22 Correct 4 ms 204 KB Output is correct
23 Correct 3 ms 204 KB Output is correct
24 Correct 4 ms 204 KB Output is correct
25 Correct 4 ms 204 KB Output is correct
26 Correct 4 ms 204 KB Output is correct
27 Correct 4 ms 204 KB Output is correct
28 Correct 4 ms 204 KB Output is correct
29 Correct 3 ms 320 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 4 ms 204 KB Output is correct
32 Correct 3 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 2 ms 204 KB Output is correct
8 Correct 2 ms 204 KB Output is correct
9 Correct 2 ms 204 KB Output is correct
10 Correct 2 ms 204 KB Output is correct
11 Correct 2 ms 204 KB Output is correct
12 Correct 2 ms 204 KB Output is correct
13 Correct 3 ms 204 KB Output is correct
14 Correct 3 ms 204 KB Output is correct
15 Correct 3 ms 204 KB Output is correct
16 Correct 4 ms 204 KB Output is correct
17 Correct 4 ms 204 KB Output is correct
18 Correct 4 ms 204 KB Output is correct
19 Correct 3 ms 204 KB Output is correct
20 Correct 4 ms 312 KB Output is correct
21 Correct 5 ms 204 KB Output is correct
22 Correct 4 ms 204 KB Output is correct
23 Correct 3 ms 204 KB Output is correct
24 Correct 4 ms 204 KB Output is correct
25 Correct 4 ms 204 KB Output is correct
26 Correct 4 ms 204 KB Output is correct
27 Correct 4 ms 204 KB Output is correct
28 Correct 4 ms 204 KB Output is correct
29 Correct 3 ms 320 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 4 ms 204 KB Output is correct
32 Correct 3 ms 204 KB Output is correct
33 Correct 15 ms 320 KB Output is correct
34 Correct 16 ms 332 KB Output is correct
35 Correct 14 ms 328 KB Output is correct
36 Correct 15 ms 332 KB Output is correct
37 Correct 14 ms 312 KB Output is correct
38 Correct 15 ms 332 KB Output is correct
39 Correct 15 ms 308 KB Output is correct
40 Correct 15 ms 332 KB Output is correct
41 Correct 16 ms 320 KB Output is correct
42 Correct 14 ms 332 KB Output is correct
43 Correct 15 ms 332 KB Output is correct
44 Correct 15 ms 328 KB Output is correct
45 Correct 14 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 613 ms 1244 KB Output is correct
2 Correct 617 ms 1388 KB Output is correct
3 Correct 612 ms 1220 KB Output is correct
4 Correct 605 ms 1220 KB Output is correct
5 Correct 625 ms 2756 KB Output is correct
6 Correct 610 ms 1348 KB Output is correct
7 Correct 606 ms 2528 KB Output is correct
8 Correct 611 ms 1996 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 2 ms 204 KB Output is correct
8 Correct 2 ms 204 KB Output is correct
9 Correct 2 ms 204 KB Output is correct
10 Correct 2 ms 204 KB Output is correct
11 Correct 2 ms 204 KB Output is correct
12 Correct 2 ms 204 KB Output is correct
13 Correct 3 ms 204 KB Output is correct
14 Correct 3 ms 204 KB Output is correct
15 Correct 3 ms 204 KB Output is correct
16 Correct 4 ms 204 KB Output is correct
17 Correct 4 ms 204 KB Output is correct
18 Correct 4 ms 204 KB Output is correct
19 Correct 3 ms 204 KB Output is correct
20 Correct 4 ms 312 KB Output is correct
21 Correct 5 ms 204 KB Output is correct
22 Correct 4 ms 204 KB Output is correct
23 Correct 3 ms 204 KB Output is correct
24 Correct 4 ms 204 KB Output is correct
25 Correct 4 ms 204 KB Output is correct
26 Correct 4 ms 204 KB Output is correct
27 Correct 4 ms 204 KB Output is correct
28 Correct 4 ms 204 KB Output is correct
29 Correct 3 ms 320 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 4 ms 204 KB Output is correct
32 Correct 3 ms 204 KB Output is correct
33 Correct 15 ms 320 KB Output is correct
34 Correct 16 ms 332 KB Output is correct
35 Correct 14 ms 328 KB Output is correct
36 Correct 15 ms 332 KB Output is correct
37 Correct 14 ms 312 KB Output is correct
38 Correct 15 ms 332 KB Output is correct
39 Correct 15 ms 308 KB Output is correct
40 Correct 15 ms 332 KB Output is correct
41 Correct 16 ms 320 KB Output is correct
42 Correct 14 ms 332 KB Output is correct
43 Correct 15 ms 332 KB Output is correct
44 Correct 15 ms 328 KB Output is correct
45 Correct 14 ms 332 KB Output is correct
46 Correct 613 ms 1244 KB Output is correct
47 Correct 617 ms 1388 KB Output is correct
48 Correct 612 ms 1220 KB Output is correct
49 Correct 605 ms 1220 KB Output is correct
50 Correct 625 ms 2756 KB Output is correct
51 Correct 610 ms 1348 KB Output is correct
52 Correct 606 ms 2528 KB Output is correct
53 Correct 611 ms 1996 KB Output is correct
54 Correct 616 ms 1368 KB Output is correct
55 Correct 614 ms 1220 KB Output is correct
56 Correct 612 ms 2672 KB Output is correct
57 Correct 614 ms 2768 KB Output is correct
58 Correct 621 ms 2628 KB Output is correct
59 Correct 620 ms 1380 KB Output is correct
60 Correct 620 ms 2564 KB Output is correct
61 Correct 617 ms 1456 KB Output is correct
62 Correct 639 ms 2636 KB Output is correct
63 Correct 599 ms 1816 KB Output is correct
64 Correct 671 ms 2156 KB Output is correct
65 Correct 602 ms 1348 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 2 ms 204 KB Output is correct
8 Correct 2 ms 204 KB Output is correct
9 Correct 2 ms 204 KB Output is correct
10 Correct 2 ms 204 KB Output is correct
11 Correct 2 ms 204 KB Output is correct
12 Correct 2 ms 204 KB Output is correct
13 Correct 3 ms 204 KB Output is correct
14 Correct 3 ms 204 KB Output is correct
15 Correct 3 ms 204 KB Output is correct
16 Correct 4 ms 204 KB Output is correct
17 Correct 4 ms 204 KB Output is correct
18 Correct 4 ms 204 KB Output is correct
19 Correct 3 ms 204 KB Output is correct
20 Correct 4 ms 312 KB Output is correct
21 Correct 5 ms 204 KB Output is correct
22 Correct 4 ms 204 KB Output is correct
23 Correct 3 ms 204 KB Output is correct
24 Correct 4 ms 204 KB Output is correct
25 Correct 4 ms 204 KB Output is correct
26 Correct 4 ms 204 KB Output is correct
27 Correct 4 ms 204 KB Output is correct
28 Correct 4 ms 204 KB Output is correct
29 Correct 3 ms 320 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 4 ms 204 KB Output is correct
32 Correct 3 ms 204 KB Output is correct
33 Correct 15 ms 320 KB Output is correct
34 Correct 16 ms 332 KB Output is correct
35 Correct 14 ms 328 KB Output is correct
36 Correct 15 ms 332 KB Output is correct
37 Correct 14 ms 312 KB Output is correct
38 Correct 15 ms 332 KB Output is correct
39 Correct 15 ms 308 KB Output is correct
40 Correct 15 ms 332 KB Output is correct
41 Correct 16 ms 320 KB Output is correct
42 Correct 14 ms 332 KB Output is correct
43 Correct 15 ms 332 KB Output is correct
44 Correct 15 ms 328 KB Output is correct
45 Correct 14 ms 332 KB Output is correct
46 Correct 613 ms 1244 KB Output is correct
47 Correct 617 ms 1388 KB Output is correct
48 Correct 612 ms 1220 KB Output is correct
49 Correct 605 ms 1220 KB Output is correct
50 Correct 625 ms 2756 KB Output is correct
51 Correct 610 ms 1348 KB Output is correct
52 Correct 606 ms 2528 KB Output is correct
53 Correct 611 ms 1996 KB Output is correct
54 Correct 616 ms 1368 KB Output is correct
55 Correct 614 ms 1220 KB Output is correct
56 Correct 612 ms 2672 KB Output is correct
57 Correct 614 ms 2768 KB Output is correct
58 Correct 621 ms 2628 KB Output is correct
59 Correct 620 ms 1380 KB Output is correct
60 Correct 620 ms 2564 KB Output is correct
61 Correct 617 ms 1456 KB Output is correct
62 Correct 639 ms 2636 KB Output is correct
63 Correct 599 ms 1816 KB Output is correct
64 Correct 671 ms 2156 KB Output is correct
65 Correct 602 ms 1348 KB Output is correct
66 Execution timed out 5019 ms 11612 KB Time limit exceeded
67 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 2 ms 204 KB Output is correct
8 Correct 2 ms 204 KB Output is correct
9 Correct 2 ms 204 KB Output is correct
10 Correct 2 ms 204 KB Output is correct
11 Correct 2 ms 204 KB Output is correct
12 Correct 2 ms 204 KB Output is correct
13 Correct 3 ms 204 KB Output is correct
14 Correct 3 ms 204 KB Output is correct
15 Correct 3 ms 204 KB Output is correct
16 Correct 4 ms 204 KB Output is correct
17 Correct 4 ms 204 KB Output is correct
18 Correct 4 ms 204 KB Output is correct
19 Correct 3 ms 204 KB Output is correct
20 Correct 4 ms 312 KB Output is correct
21 Correct 5 ms 204 KB Output is correct
22 Correct 4 ms 204 KB Output is correct
23 Correct 3 ms 204 KB Output is correct
24 Correct 4 ms 204 KB Output is correct
25 Correct 4 ms 204 KB Output is correct
26 Correct 4 ms 204 KB Output is correct
27 Correct 4 ms 204 KB Output is correct
28 Correct 4 ms 204 KB Output is correct
29 Correct 3 ms 320 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 4 ms 204 KB Output is correct
32 Correct 3 ms 204 KB Output is correct
33 Correct 15 ms 320 KB Output is correct
34 Correct 16 ms 332 KB Output is correct
35 Correct 14 ms 328 KB Output is correct
36 Correct 15 ms 332 KB Output is correct
37 Correct 14 ms 312 KB Output is correct
38 Correct 15 ms 332 KB Output is correct
39 Correct 15 ms 308 KB Output is correct
40 Correct 15 ms 332 KB Output is correct
41 Correct 16 ms 320 KB Output is correct
42 Correct 14 ms 332 KB Output is correct
43 Correct 15 ms 332 KB Output is correct
44 Correct 15 ms 328 KB Output is correct
45 Correct 14 ms 332 KB Output is correct
46 Correct 613 ms 1244 KB Output is correct
47 Correct 617 ms 1388 KB Output is correct
48 Correct 612 ms 1220 KB Output is correct
49 Correct 605 ms 1220 KB Output is correct
50 Correct 625 ms 2756 KB Output is correct
51 Correct 610 ms 1348 KB Output is correct
52 Correct 606 ms 2528 KB Output is correct
53 Correct 611 ms 1996 KB Output is correct
54 Correct 616 ms 1368 KB Output is correct
55 Correct 614 ms 1220 KB Output is correct
56 Correct 612 ms 2672 KB Output is correct
57 Correct 614 ms 2768 KB Output is correct
58 Correct 621 ms 2628 KB Output is correct
59 Correct 620 ms 1380 KB Output is correct
60 Correct 620 ms 2564 KB Output is correct
61 Correct 617 ms 1456 KB Output is correct
62 Correct 639 ms 2636 KB Output is correct
63 Correct 599 ms 1816 KB Output is correct
64 Correct 671 ms 2156 KB Output is correct
65 Correct 602 ms 1348 KB Output is correct
66 Execution timed out 5073 ms 12284 KB Time limit exceeded
67 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 2 ms 204 KB Output is correct
8 Correct 2 ms 204 KB Output is correct
9 Correct 2 ms 204 KB Output is correct
10 Correct 2 ms 204 KB Output is correct
11 Correct 2 ms 204 KB Output is correct
12 Correct 2 ms 204 KB Output is correct
13 Correct 3 ms 204 KB Output is correct
14 Correct 3 ms 204 KB Output is correct
15 Correct 3 ms 204 KB Output is correct
16 Correct 4 ms 204 KB Output is correct
17 Correct 4 ms 204 KB Output is correct
18 Correct 4 ms 204 KB Output is correct
19 Correct 3 ms 204 KB Output is correct
20 Correct 4 ms 312 KB Output is correct
21 Correct 5 ms 204 KB Output is correct
22 Correct 4 ms 204 KB Output is correct
23 Correct 3 ms 204 KB Output is correct
24 Correct 4 ms 204 KB Output is correct
25 Correct 4 ms 204 KB Output is correct
26 Correct 4 ms 204 KB Output is correct
27 Correct 4 ms 204 KB Output is correct
28 Correct 4 ms 204 KB Output is correct
29 Correct 3 ms 320 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 4 ms 204 KB Output is correct
32 Correct 3 ms 204 KB Output is correct
33 Correct 15 ms 320 KB Output is correct
34 Correct 16 ms 332 KB Output is correct
35 Correct 14 ms 328 KB Output is correct
36 Correct 15 ms 332 KB Output is correct
37 Correct 14 ms 312 KB Output is correct
38 Correct 15 ms 332 KB Output is correct
39 Correct 15 ms 308 KB Output is correct
40 Correct 15 ms 332 KB Output is correct
41 Correct 16 ms 320 KB Output is correct
42 Correct 14 ms 332 KB Output is correct
43 Correct 15 ms 332 KB Output is correct
44 Correct 15 ms 328 KB Output is correct
45 Correct 14 ms 332 KB Output is correct
46 Correct 613 ms 1244 KB Output is correct
47 Correct 617 ms 1388 KB Output is correct
48 Correct 612 ms 1220 KB Output is correct
49 Correct 605 ms 1220 KB Output is correct
50 Correct 625 ms 2756 KB Output is correct
51 Correct 610 ms 1348 KB Output is correct
52 Correct 606 ms 2528 KB Output is correct
53 Correct 611 ms 1996 KB Output is correct
54 Correct 616 ms 1368 KB Output is correct
55 Correct 614 ms 1220 KB Output is correct
56 Correct 612 ms 2672 KB Output is correct
57 Correct 614 ms 2768 KB Output is correct
58 Correct 621 ms 2628 KB Output is correct
59 Correct 620 ms 1380 KB Output is correct
60 Correct 620 ms 2564 KB Output is correct
61 Correct 617 ms 1456 KB Output is correct
62 Correct 639 ms 2636 KB Output is correct
63 Correct 599 ms 1816 KB Output is correct
64 Correct 671 ms 2156 KB Output is correct
65 Correct 602 ms 1348 KB Output is correct
66 Execution timed out 5019 ms 11612 KB Time limit exceeded
67 Halted 0 ms 0 KB -