답안 #525007

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
525007 2022-02-10T12:53:28 Z blue IOI 바이러스 (JOI21_fever) C++17
25 / 100
5000 ms 11856 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 308 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 4 ms 332 KB Output is correct
14 Correct 3 ms 204 KB Output is correct
15 Correct 4 ms 204 KB Output is correct
16 Correct 4 ms 204 KB Output is correct
17 Correct 5 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 204 KB Output is correct
21 Correct 4 ms 204 KB Output is correct
22 Correct 4 ms 312 KB Output is correct
23 Correct 3 ms 204 KB Output is correct
24 Correct 4 ms 284 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 316 KB Output is correct
29 Correct 4 ms 204 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 308 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 4 ms 332 KB Output is correct
14 Correct 3 ms 204 KB Output is correct
15 Correct 4 ms 204 KB Output is correct
16 Correct 4 ms 204 KB Output is correct
17 Correct 5 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 204 KB Output is correct
21 Correct 4 ms 204 KB Output is correct
22 Correct 4 ms 312 KB Output is correct
23 Correct 3 ms 204 KB Output is correct
24 Correct 4 ms 284 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 316 KB Output is correct
29 Correct 4 ms 204 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 14 ms 332 KB Output is correct
34 Correct 15 ms 328 KB Output is correct
35 Correct 16 ms 320 KB Output is correct
36 Correct 14 ms 332 KB Output is correct
37 Correct 14 ms 332 KB Output is correct
38 Correct 15 ms 328 KB Output is correct
39 Correct 19 ms 336 KB Output is correct
40 Correct 15 ms 348 KB Output is correct
41 Correct 15 ms 332 KB Output is correct
42 Correct 15 ms 348 KB Output is correct
43 Correct 14 ms 332 KB Output is correct
44 Correct 15 ms 332 KB Output is correct
45 Correct 16 ms 320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 622 ms 1352 KB Output is correct
2 Correct 608 ms 1216 KB Output is correct
3 Correct 608 ms 1264 KB Output is correct
4 Correct 606 ms 1348 KB Output is correct
5 Correct 613 ms 2756 KB Output is correct
6 Correct 605 ms 1348 KB Output is correct
7 Correct 598 ms 2500 KB Output is correct
8 Correct 621 ms 1972 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 308 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 4 ms 332 KB Output is correct
14 Correct 3 ms 204 KB Output is correct
15 Correct 4 ms 204 KB Output is correct
16 Correct 4 ms 204 KB Output is correct
17 Correct 5 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 204 KB Output is correct
21 Correct 4 ms 204 KB Output is correct
22 Correct 4 ms 312 KB Output is correct
23 Correct 3 ms 204 KB Output is correct
24 Correct 4 ms 284 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 316 KB Output is correct
29 Correct 4 ms 204 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 14 ms 332 KB Output is correct
34 Correct 15 ms 328 KB Output is correct
35 Correct 16 ms 320 KB Output is correct
36 Correct 14 ms 332 KB Output is correct
37 Correct 14 ms 332 KB Output is correct
38 Correct 15 ms 328 KB Output is correct
39 Correct 19 ms 336 KB Output is correct
40 Correct 15 ms 348 KB Output is correct
41 Correct 15 ms 332 KB Output is correct
42 Correct 15 ms 348 KB Output is correct
43 Correct 14 ms 332 KB Output is correct
44 Correct 15 ms 332 KB Output is correct
45 Correct 16 ms 320 KB Output is correct
46 Correct 622 ms 1352 KB Output is correct
47 Correct 608 ms 1216 KB Output is correct
48 Correct 608 ms 1264 KB Output is correct
49 Correct 606 ms 1348 KB Output is correct
50 Correct 613 ms 2756 KB Output is correct
51 Correct 605 ms 1348 KB Output is correct
52 Correct 598 ms 2500 KB Output is correct
53 Correct 621 ms 1972 KB Output is correct
54 Correct 630 ms 1268 KB Output is correct
55 Correct 594 ms 1232 KB Output is correct
56 Correct 621 ms 2628 KB Output is correct
57 Correct 614 ms 2724 KB Output is correct
58 Correct 621 ms 2632 KB Output is correct
59 Correct 660 ms 1320 KB Output is correct
60 Correct 624 ms 2500 KB Output is correct
61 Correct 626 ms 1424 KB Output is correct
62 Correct 607 ms 2676 KB Output is correct
63 Correct 650 ms 1720 KB Output is correct
64 Correct 717 ms 2220 KB Output is correct
65 Correct 622 ms 1572 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 308 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 4 ms 332 KB Output is correct
14 Correct 3 ms 204 KB Output is correct
15 Correct 4 ms 204 KB Output is correct
16 Correct 4 ms 204 KB Output is correct
17 Correct 5 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 204 KB Output is correct
21 Correct 4 ms 204 KB Output is correct
22 Correct 4 ms 312 KB Output is correct
23 Correct 3 ms 204 KB Output is correct
24 Correct 4 ms 284 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 316 KB Output is correct
29 Correct 4 ms 204 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 14 ms 332 KB Output is correct
34 Correct 15 ms 328 KB Output is correct
35 Correct 16 ms 320 KB Output is correct
36 Correct 14 ms 332 KB Output is correct
37 Correct 14 ms 332 KB Output is correct
38 Correct 15 ms 328 KB Output is correct
39 Correct 19 ms 336 KB Output is correct
40 Correct 15 ms 348 KB Output is correct
41 Correct 15 ms 332 KB Output is correct
42 Correct 15 ms 348 KB Output is correct
43 Correct 14 ms 332 KB Output is correct
44 Correct 15 ms 332 KB Output is correct
45 Correct 16 ms 320 KB Output is correct
46 Correct 622 ms 1352 KB Output is correct
47 Correct 608 ms 1216 KB Output is correct
48 Correct 608 ms 1264 KB Output is correct
49 Correct 606 ms 1348 KB Output is correct
50 Correct 613 ms 2756 KB Output is correct
51 Correct 605 ms 1348 KB Output is correct
52 Correct 598 ms 2500 KB Output is correct
53 Correct 621 ms 1972 KB Output is correct
54 Correct 630 ms 1268 KB Output is correct
55 Correct 594 ms 1232 KB Output is correct
56 Correct 621 ms 2628 KB Output is correct
57 Correct 614 ms 2724 KB Output is correct
58 Correct 621 ms 2632 KB Output is correct
59 Correct 660 ms 1320 KB Output is correct
60 Correct 624 ms 2500 KB Output is correct
61 Correct 626 ms 1424 KB Output is correct
62 Correct 607 ms 2676 KB Output is correct
63 Correct 650 ms 1720 KB Output is correct
64 Correct 717 ms 2220 KB Output is correct
65 Correct 622 ms 1572 KB Output is correct
66 Execution timed out 5052 ms 11664 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 308 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 4 ms 332 KB Output is correct
14 Correct 3 ms 204 KB Output is correct
15 Correct 4 ms 204 KB Output is correct
16 Correct 4 ms 204 KB Output is correct
17 Correct 5 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 204 KB Output is correct
21 Correct 4 ms 204 KB Output is correct
22 Correct 4 ms 312 KB Output is correct
23 Correct 3 ms 204 KB Output is correct
24 Correct 4 ms 284 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 316 KB Output is correct
29 Correct 4 ms 204 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 14 ms 332 KB Output is correct
34 Correct 15 ms 328 KB Output is correct
35 Correct 16 ms 320 KB Output is correct
36 Correct 14 ms 332 KB Output is correct
37 Correct 14 ms 332 KB Output is correct
38 Correct 15 ms 328 KB Output is correct
39 Correct 19 ms 336 KB Output is correct
40 Correct 15 ms 348 KB Output is correct
41 Correct 15 ms 332 KB Output is correct
42 Correct 15 ms 348 KB Output is correct
43 Correct 14 ms 332 KB Output is correct
44 Correct 15 ms 332 KB Output is correct
45 Correct 16 ms 320 KB Output is correct
46 Correct 622 ms 1352 KB Output is correct
47 Correct 608 ms 1216 KB Output is correct
48 Correct 608 ms 1264 KB Output is correct
49 Correct 606 ms 1348 KB Output is correct
50 Correct 613 ms 2756 KB Output is correct
51 Correct 605 ms 1348 KB Output is correct
52 Correct 598 ms 2500 KB Output is correct
53 Correct 621 ms 1972 KB Output is correct
54 Correct 630 ms 1268 KB Output is correct
55 Correct 594 ms 1232 KB Output is correct
56 Correct 621 ms 2628 KB Output is correct
57 Correct 614 ms 2724 KB Output is correct
58 Correct 621 ms 2632 KB Output is correct
59 Correct 660 ms 1320 KB Output is correct
60 Correct 624 ms 2500 KB Output is correct
61 Correct 626 ms 1424 KB Output is correct
62 Correct 607 ms 2676 KB Output is correct
63 Correct 650 ms 1720 KB Output is correct
64 Correct 717 ms 2220 KB Output is correct
65 Correct 622 ms 1572 KB Output is correct
66 Execution timed out 5055 ms 11856 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 308 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 4 ms 332 KB Output is correct
14 Correct 3 ms 204 KB Output is correct
15 Correct 4 ms 204 KB Output is correct
16 Correct 4 ms 204 KB Output is correct
17 Correct 5 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 204 KB Output is correct
21 Correct 4 ms 204 KB Output is correct
22 Correct 4 ms 312 KB Output is correct
23 Correct 3 ms 204 KB Output is correct
24 Correct 4 ms 284 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 316 KB Output is correct
29 Correct 4 ms 204 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 14 ms 332 KB Output is correct
34 Correct 15 ms 328 KB Output is correct
35 Correct 16 ms 320 KB Output is correct
36 Correct 14 ms 332 KB Output is correct
37 Correct 14 ms 332 KB Output is correct
38 Correct 15 ms 328 KB Output is correct
39 Correct 19 ms 336 KB Output is correct
40 Correct 15 ms 348 KB Output is correct
41 Correct 15 ms 332 KB Output is correct
42 Correct 15 ms 348 KB Output is correct
43 Correct 14 ms 332 KB Output is correct
44 Correct 15 ms 332 KB Output is correct
45 Correct 16 ms 320 KB Output is correct
46 Correct 622 ms 1352 KB Output is correct
47 Correct 608 ms 1216 KB Output is correct
48 Correct 608 ms 1264 KB Output is correct
49 Correct 606 ms 1348 KB Output is correct
50 Correct 613 ms 2756 KB Output is correct
51 Correct 605 ms 1348 KB Output is correct
52 Correct 598 ms 2500 KB Output is correct
53 Correct 621 ms 1972 KB Output is correct
54 Correct 630 ms 1268 KB Output is correct
55 Correct 594 ms 1232 KB Output is correct
56 Correct 621 ms 2628 KB Output is correct
57 Correct 614 ms 2724 KB Output is correct
58 Correct 621 ms 2632 KB Output is correct
59 Correct 660 ms 1320 KB Output is correct
60 Correct 624 ms 2500 KB Output is correct
61 Correct 626 ms 1424 KB Output is correct
62 Correct 607 ms 2676 KB Output is correct
63 Correct 650 ms 1720 KB Output is correct
64 Correct 717 ms 2220 KB Output is correct
65 Correct 622 ms 1572 KB Output is correct
66 Execution timed out 5052 ms 11664 KB Time limit exceeded
67 Halted 0 ms 0 KB -