Submission #525009

# Submission time Handle Problem Language Result Execution time Memory
525009 2022-02-10T12:54:02 Z blue IOI Fever (JOI21_fever) C++17
25 / 100
5000 ms 11872 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';
}
# Verdict Execution time Memory Grader output
1 Correct 0 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 2 ms 204 KB Output is correct
9 Correct 1 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 312 KB Output is correct
15 Correct 3 ms 204 KB Output is correct
16 Correct 3 ms 204 KB Output is correct
17 Correct 4 ms 204 KB Output is correct
18 Correct 4 ms 316 KB Output is correct
19 Correct 4 ms 204 KB Output is correct
20 Correct 4 ms 204 KB Output is correct
21 Correct 3 ms 204 KB Output is correct
22 Correct 4 ms 204 KB Output is correct
23 Correct 4 ms 204 KB Output is correct
24 Correct 5 ms 308 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 320 KB Output is correct
28 Correct 4 ms 204 KB Output is correct
29 Correct 3 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 4 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 2 ms 204 KB Output is correct
9 Correct 1 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 312 KB Output is correct
15 Correct 3 ms 204 KB Output is correct
16 Correct 3 ms 204 KB Output is correct
17 Correct 4 ms 204 KB Output is correct
18 Correct 4 ms 316 KB Output is correct
19 Correct 4 ms 204 KB Output is correct
20 Correct 4 ms 204 KB Output is correct
21 Correct 3 ms 204 KB Output is correct
22 Correct 4 ms 204 KB Output is correct
23 Correct 4 ms 204 KB Output is correct
24 Correct 5 ms 308 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 320 KB Output is correct
28 Correct 4 ms 204 KB Output is correct
29 Correct 3 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 4 ms 204 KB Output is correct
33 Correct 14 ms 316 KB Output is correct
34 Correct 14 ms 204 KB Output is correct
35 Correct 15 ms 328 KB Output is correct
36 Correct 14 ms 340 KB Output is correct
37 Correct 15 ms 204 KB Output is correct
38 Correct 14 ms 324 KB Output is correct
39 Correct 15 ms 332 KB Output is correct
40 Correct 15 ms 352 KB Output is correct
41 Correct 16 ms 364 KB Output is correct
42 Correct 15 ms 452 KB Output is correct
43 Correct 15 ms 308 KB Output is correct
44 Correct 15 ms 336 KB Output is correct
45 Correct 15 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 600 ms 1268 KB Output is correct
2 Correct 614 ms 1368 KB Output is correct
3 Correct 599 ms 1360 KB Output is correct
4 Correct 609 ms 1364 KB Output is correct
5 Correct 607 ms 2648 KB Output is correct
6 Correct 621 ms 1372 KB Output is correct
7 Correct 623 ms 2592 KB Output is correct
8 Correct 607 ms 1972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 2 ms 204 KB Output is correct
9 Correct 1 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 312 KB Output is correct
15 Correct 3 ms 204 KB Output is correct
16 Correct 3 ms 204 KB Output is correct
17 Correct 4 ms 204 KB Output is correct
18 Correct 4 ms 316 KB Output is correct
19 Correct 4 ms 204 KB Output is correct
20 Correct 4 ms 204 KB Output is correct
21 Correct 3 ms 204 KB Output is correct
22 Correct 4 ms 204 KB Output is correct
23 Correct 4 ms 204 KB Output is correct
24 Correct 5 ms 308 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 320 KB Output is correct
28 Correct 4 ms 204 KB Output is correct
29 Correct 3 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 4 ms 204 KB Output is correct
33 Correct 14 ms 316 KB Output is correct
34 Correct 14 ms 204 KB Output is correct
35 Correct 15 ms 328 KB Output is correct
36 Correct 14 ms 340 KB Output is correct
37 Correct 15 ms 204 KB Output is correct
38 Correct 14 ms 324 KB Output is correct
39 Correct 15 ms 332 KB Output is correct
40 Correct 15 ms 352 KB Output is correct
41 Correct 16 ms 364 KB Output is correct
42 Correct 15 ms 452 KB Output is correct
43 Correct 15 ms 308 KB Output is correct
44 Correct 15 ms 336 KB Output is correct
45 Correct 15 ms 332 KB Output is correct
46 Correct 600 ms 1268 KB Output is correct
47 Correct 614 ms 1368 KB Output is correct
48 Correct 599 ms 1360 KB Output is correct
49 Correct 609 ms 1364 KB Output is correct
50 Correct 607 ms 2648 KB Output is correct
51 Correct 621 ms 1372 KB Output is correct
52 Correct 623 ms 2592 KB Output is correct
53 Correct 607 ms 1972 KB Output is correct
54 Correct 606 ms 1260 KB Output is correct
55 Correct 607 ms 1312 KB Output is correct
56 Correct 611 ms 2628 KB Output is correct
57 Correct 616 ms 2668 KB Output is correct
58 Correct 634 ms 2788 KB Output is correct
59 Correct 629 ms 1332 KB Output is correct
60 Correct 615 ms 2568 KB Output is correct
61 Correct 598 ms 1352 KB Output is correct
62 Correct 633 ms 2784 KB Output is correct
63 Correct 624 ms 1860 KB Output is correct
64 Correct 635 ms 2244 KB Output is correct
65 Correct 600 ms 1432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 2 ms 204 KB Output is correct
9 Correct 1 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 312 KB Output is correct
15 Correct 3 ms 204 KB Output is correct
16 Correct 3 ms 204 KB Output is correct
17 Correct 4 ms 204 KB Output is correct
18 Correct 4 ms 316 KB Output is correct
19 Correct 4 ms 204 KB Output is correct
20 Correct 4 ms 204 KB Output is correct
21 Correct 3 ms 204 KB Output is correct
22 Correct 4 ms 204 KB Output is correct
23 Correct 4 ms 204 KB Output is correct
24 Correct 5 ms 308 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 320 KB Output is correct
28 Correct 4 ms 204 KB Output is correct
29 Correct 3 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 4 ms 204 KB Output is correct
33 Correct 14 ms 316 KB Output is correct
34 Correct 14 ms 204 KB Output is correct
35 Correct 15 ms 328 KB Output is correct
36 Correct 14 ms 340 KB Output is correct
37 Correct 15 ms 204 KB Output is correct
38 Correct 14 ms 324 KB Output is correct
39 Correct 15 ms 332 KB Output is correct
40 Correct 15 ms 352 KB Output is correct
41 Correct 16 ms 364 KB Output is correct
42 Correct 15 ms 452 KB Output is correct
43 Correct 15 ms 308 KB Output is correct
44 Correct 15 ms 336 KB Output is correct
45 Correct 15 ms 332 KB Output is correct
46 Correct 600 ms 1268 KB Output is correct
47 Correct 614 ms 1368 KB Output is correct
48 Correct 599 ms 1360 KB Output is correct
49 Correct 609 ms 1364 KB Output is correct
50 Correct 607 ms 2648 KB Output is correct
51 Correct 621 ms 1372 KB Output is correct
52 Correct 623 ms 2592 KB Output is correct
53 Correct 607 ms 1972 KB Output is correct
54 Correct 606 ms 1260 KB Output is correct
55 Correct 607 ms 1312 KB Output is correct
56 Correct 611 ms 2628 KB Output is correct
57 Correct 616 ms 2668 KB Output is correct
58 Correct 634 ms 2788 KB Output is correct
59 Correct 629 ms 1332 KB Output is correct
60 Correct 615 ms 2568 KB Output is correct
61 Correct 598 ms 1352 KB Output is correct
62 Correct 633 ms 2784 KB Output is correct
63 Correct 624 ms 1860 KB Output is correct
64 Correct 635 ms 2244 KB Output is correct
65 Correct 600 ms 1432 KB Output is correct
66 Execution timed out 5061 ms 11572 KB Time limit exceeded
67 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 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 2 ms 204 KB Output is correct
9 Correct 1 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 312 KB Output is correct
15 Correct 3 ms 204 KB Output is correct
16 Correct 3 ms 204 KB Output is correct
17 Correct 4 ms 204 KB Output is correct
18 Correct 4 ms 316 KB Output is correct
19 Correct 4 ms 204 KB Output is correct
20 Correct 4 ms 204 KB Output is correct
21 Correct 3 ms 204 KB Output is correct
22 Correct 4 ms 204 KB Output is correct
23 Correct 4 ms 204 KB Output is correct
24 Correct 5 ms 308 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 320 KB Output is correct
28 Correct 4 ms 204 KB Output is correct
29 Correct 3 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 4 ms 204 KB Output is correct
33 Correct 14 ms 316 KB Output is correct
34 Correct 14 ms 204 KB Output is correct
35 Correct 15 ms 328 KB Output is correct
36 Correct 14 ms 340 KB Output is correct
37 Correct 15 ms 204 KB Output is correct
38 Correct 14 ms 324 KB Output is correct
39 Correct 15 ms 332 KB Output is correct
40 Correct 15 ms 352 KB Output is correct
41 Correct 16 ms 364 KB Output is correct
42 Correct 15 ms 452 KB Output is correct
43 Correct 15 ms 308 KB Output is correct
44 Correct 15 ms 336 KB Output is correct
45 Correct 15 ms 332 KB Output is correct
46 Correct 600 ms 1268 KB Output is correct
47 Correct 614 ms 1368 KB Output is correct
48 Correct 599 ms 1360 KB Output is correct
49 Correct 609 ms 1364 KB Output is correct
50 Correct 607 ms 2648 KB Output is correct
51 Correct 621 ms 1372 KB Output is correct
52 Correct 623 ms 2592 KB Output is correct
53 Correct 607 ms 1972 KB Output is correct
54 Correct 606 ms 1260 KB Output is correct
55 Correct 607 ms 1312 KB Output is correct
56 Correct 611 ms 2628 KB Output is correct
57 Correct 616 ms 2668 KB Output is correct
58 Correct 634 ms 2788 KB Output is correct
59 Correct 629 ms 1332 KB Output is correct
60 Correct 615 ms 2568 KB Output is correct
61 Correct 598 ms 1352 KB Output is correct
62 Correct 633 ms 2784 KB Output is correct
63 Correct 624 ms 1860 KB Output is correct
64 Correct 635 ms 2244 KB Output is correct
65 Correct 600 ms 1432 KB Output is correct
66 Execution timed out 5072 ms 11872 KB Time limit exceeded
67 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 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 2 ms 204 KB Output is correct
9 Correct 1 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 312 KB Output is correct
15 Correct 3 ms 204 KB Output is correct
16 Correct 3 ms 204 KB Output is correct
17 Correct 4 ms 204 KB Output is correct
18 Correct 4 ms 316 KB Output is correct
19 Correct 4 ms 204 KB Output is correct
20 Correct 4 ms 204 KB Output is correct
21 Correct 3 ms 204 KB Output is correct
22 Correct 4 ms 204 KB Output is correct
23 Correct 4 ms 204 KB Output is correct
24 Correct 5 ms 308 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 320 KB Output is correct
28 Correct 4 ms 204 KB Output is correct
29 Correct 3 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 4 ms 204 KB Output is correct
33 Correct 14 ms 316 KB Output is correct
34 Correct 14 ms 204 KB Output is correct
35 Correct 15 ms 328 KB Output is correct
36 Correct 14 ms 340 KB Output is correct
37 Correct 15 ms 204 KB Output is correct
38 Correct 14 ms 324 KB Output is correct
39 Correct 15 ms 332 KB Output is correct
40 Correct 15 ms 352 KB Output is correct
41 Correct 16 ms 364 KB Output is correct
42 Correct 15 ms 452 KB Output is correct
43 Correct 15 ms 308 KB Output is correct
44 Correct 15 ms 336 KB Output is correct
45 Correct 15 ms 332 KB Output is correct
46 Correct 600 ms 1268 KB Output is correct
47 Correct 614 ms 1368 KB Output is correct
48 Correct 599 ms 1360 KB Output is correct
49 Correct 609 ms 1364 KB Output is correct
50 Correct 607 ms 2648 KB Output is correct
51 Correct 621 ms 1372 KB Output is correct
52 Correct 623 ms 2592 KB Output is correct
53 Correct 607 ms 1972 KB Output is correct
54 Correct 606 ms 1260 KB Output is correct
55 Correct 607 ms 1312 KB Output is correct
56 Correct 611 ms 2628 KB Output is correct
57 Correct 616 ms 2668 KB Output is correct
58 Correct 634 ms 2788 KB Output is correct
59 Correct 629 ms 1332 KB Output is correct
60 Correct 615 ms 2568 KB Output is correct
61 Correct 598 ms 1352 KB Output is correct
62 Correct 633 ms 2784 KB Output is correct
63 Correct 624 ms 1860 KB Output is correct
64 Correct 635 ms 2244 KB Output is correct
65 Correct 600 ms 1432 KB Output is correct
66 Execution timed out 5061 ms 11572 KB Time limit exceeded
67 Halted 0 ms 0 KB -