Submission #801222

# Submission time Handle Problem Language Result Execution time Memory
801222 2023-08-02T05:07:11 Z 이성호(#10091) IOI Fever (JOI21_fever) C++17
37 / 100
550 ms 40104 KB
#include <iostream>
#include <cassert>
#include <vector>
#include <algorithm>
using namespace std;
struct Dot
{
    int x, y;
    Dot operator-(Dot d)
    {
        return {x - d.x, y - d.y};
    }
};
int N;
Dot dot[3005];
int dir[3005];
bool infect[3005];
Dot mv[4];
int coll(int i, int j)
{
    if (dir[i] == dir[j]) return -1;
    Dot del = dot[j] - dot[i], ver = mv[dir[i]] - mv[dir[j]];
    if (ver.x < 0) {
        ver.x *= -1; del.x *= -1;
    }
    if (ver.y < 0) {
        ver.y *= -1; del.y *= -1;
    }
    if (del.x < 0 || del.y < 0) return -1;
    if (ver.y == 0) {
        if (del.y) return -1;
        return del.x * 2 / ver.x;
    }
    if (ver.x == 0) {
        if (del.x) return -1;
        return del.y * 2 / ver.y;
    }
    return del.y / ver.y == del.x / ver.x ? (2 * del.y / ver.y) : -1;
}
int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //freopen("sample-05-in.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    mv[0] = {1, 0};
    mv[1] = {0, 1};
    mv[2] = {-1, 0};
    mv[3] = {0, -1};
    cin >> N;
    for (int i = 1; i <= N; i++) {
        cin >> dot[i].x >> dot[i].y;
        if (i >= 2) {
            dot[i].x -= dot[1].x;
            dot[i].y -= dot[1].y;
        }
    }
    dot[1] = {0, 0};
    int ans = 0;
    for (int k = 0; k < 4; k++) {
        for (int i = 2; i <= N; i++) {
            int tmp = dot[i].y;
            dot[i].y = dot[i].x;
            dot[i].x = -tmp;
        }
        dir[1] = 0;
        for (int i = 2; i <= N; i++) {
            if (dot[i].y < dot[i].x && -dot[i].x < dot[i].y) {
                dir[i] = 2;
            }
            else if (dot[i].y >= dot[i].x && dot[i].y > -dot[i].x) {
                dir[i] = 3;
            }
            else if (dot[i].y < dot[i].x && dot[i].y <= -dot[i].x) {
                dir[i] = 1;
            }
            else if (dot[i].y >= dot[i].x && dot[i].y <= -dot[i].x) {
                dir[i] = 0;
            }
            else {
                assert(0);
            }
        }
        vector<pair<int, pair<int, int>>> vc;
        for (int i = 1; i <= N; i++) {
            for (int j = i + 1; j <= N; j++) {
                int tmp = coll(i, j);
                if (tmp != -1) vc.push_back(make_pair(tmp, make_pair(i, j)));
            }
        }
        sort(vc.begin(), vc.end());
        fill(infect, infect + 3005, false);
        infect[1] = true;
        for (auto p:vc) {
            if (infect[p.second.first] || infect[p.second.second]) {
                infect[p.second.first] = infect[p.second.second] = true;
            }
        }
        int res = 0;
        for (int i = 1; i <= N; i++) res += infect[i];
        ans = max(ans, res);
    }
    cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 328 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 252 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 328 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 1 ms 328 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 340 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 328 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 252 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 328 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 1 ms 328 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 340 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 0 ms 332 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 340 KB Output is correct
43 Correct 1 ms 324 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 328 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 252 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 328 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 1 ms 328 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 340 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 0 ms 332 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 340 KB Output is correct
43 Correct 1 ms 324 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 1 ms 340 KB Output is correct
51 Correct 1 ms 340 KB Output is correct
52 Correct 1 ms 340 KB Output is correct
53 Correct 1 ms 340 KB Output is correct
54 Correct 1 ms 212 KB Output is correct
55 Correct 1 ms 340 KB Output is correct
56 Correct 1 ms 212 KB Output is correct
57 Correct 1 ms 212 KB Output is correct
58 Correct 1 ms 340 KB Output is correct
59 Correct 1 ms 340 KB Output is correct
60 Correct 1 ms 340 KB Output is correct
61 Correct 1 ms 332 KB Output is correct
62 Correct 1 ms 328 KB Output is correct
63 Correct 1 ms 328 KB Output is correct
64 Correct 1 ms 212 KB Output is correct
65 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 328 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 252 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 328 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 1 ms 328 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 340 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 0 ms 332 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 340 KB Output is correct
43 Correct 1 ms 324 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 1 ms 340 KB Output is correct
51 Correct 1 ms 340 KB Output is correct
52 Correct 1 ms 340 KB Output is correct
53 Correct 1 ms 340 KB Output is correct
54 Correct 1 ms 212 KB Output is correct
55 Correct 1 ms 340 KB Output is correct
56 Correct 1 ms 212 KB Output is correct
57 Correct 1 ms 212 KB Output is correct
58 Correct 1 ms 340 KB Output is correct
59 Correct 1 ms 340 KB Output is correct
60 Correct 1 ms 340 KB Output is correct
61 Correct 1 ms 332 KB Output is correct
62 Correct 1 ms 328 KB Output is correct
63 Correct 1 ms 328 KB Output is correct
64 Correct 1 ms 212 KB Output is correct
65 Correct 1 ms 340 KB Output is correct
66 Correct 131 ms 620 KB Output is correct
67 Correct 118 ms 392 KB Output is correct
68 Correct 195 ms 400 KB Output is correct
69 Correct 205 ms 1508 KB Output is correct
70 Correct 132 ms 540 KB Output is correct
71 Correct 141 ms 492 KB Output is correct
72 Correct 165 ms 392 KB Output is correct
73 Correct 190 ms 400 KB Output is correct
74 Correct 40 ms 368 KB Output is correct
75 Correct 317 ms 20024 KB Output is correct
76 Correct 221 ms 1728 KB Output is correct
77 Correct 188 ms 2848 KB Output is correct
78 Correct 194 ms 428 KB Output is correct
79 Correct 202 ms 444 KB Output is correct
80 Correct 197 ms 460 KB Output is correct
81 Correct 198 ms 424 KB Output is correct
82 Correct 138 ms 9644 KB Output is correct
83 Correct 550 ms 40104 KB Output is correct
84 Correct 40 ms 400 KB Output is correct
85 Correct 50 ms 412 KB Output is correct
86 Correct 131 ms 960 KB Output is correct
87 Correct 50 ms 396 KB Output is correct
88 Correct 42 ms 472 KB Output is correct
89 Correct 179 ms 432 KB Output is correct
90 Correct 211 ms 484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 328 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 252 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 328 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 1 ms 328 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 340 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 0 ms 332 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 340 KB Output is correct
43 Correct 1 ms 324 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 1 ms 340 KB Output is correct
51 Correct 1 ms 340 KB Output is correct
52 Correct 1 ms 340 KB Output is correct
53 Correct 1 ms 340 KB Output is correct
54 Correct 1 ms 212 KB Output is correct
55 Correct 1 ms 340 KB Output is correct
56 Correct 1 ms 212 KB Output is correct
57 Correct 1 ms 212 KB Output is correct
58 Correct 1 ms 340 KB Output is correct
59 Correct 1 ms 340 KB Output is correct
60 Correct 1 ms 340 KB Output is correct
61 Correct 1 ms 332 KB Output is correct
62 Correct 1 ms 328 KB Output is correct
63 Correct 1 ms 328 KB Output is correct
64 Correct 1 ms 212 KB Output is correct
65 Correct 1 ms 340 KB Output is correct
66 Runtime error 1 ms 468 KB Execution killed with signal 11
67 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 328 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 252 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 328 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 1 ms 328 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 340 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 0 ms 332 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 340 KB Output is correct
43 Correct 1 ms 324 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 1 ms 340 KB Output is correct
51 Correct 1 ms 340 KB Output is correct
52 Correct 1 ms 340 KB Output is correct
53 Correct 1 ms 340 KB Output is correct
54 Correct 1 ms 212 KB Output is correct
55 Correct 1 ms 340 KB Output is correct
56 Correct 1 ms 212 KB Output is correct
57 Correct 1 ms 212 KB Output is correct
58 Correct 1 ms 340 KB Output is correct
59 Correct 1 ms 340 KB Output is correct
60 Correct 1 ms 340 KB Output is correct
61 Correct 1 ms 332 KB Output is correct
62 Correct 1 ms 328 KB Output is correct
63 Correct 1 ms 328 KB Output is correct
64 Correct 1 ms 212 KB Output is correct
65 Correct 1 ms 340 KB Output is correct
66 Correct 131 ms 620 KB Output is correct
67 Correct 118 ms 392 KB Output is correct
68 Correct 195 ms 400 KB Output is correct
69 Correct 205 ms 1508 KB Output is correct
70 Correct 132 ms 540 KB Output is correct
71 Correct 141 ms 492 KB Output is correct
72 Correct 165 ms 392 KB Output is correct
73 Correct 190 ms 400 KB Output is correct
74 Correct 40 ms 368 KB Output is correct
75 Correct 317 ms 20024 KB Output is correct
76 Correct 221 ms 1728 KB Output is correct
77 Correct 188 ms 2848 KB Output is correct
78 Correct 194 ms 428 KB Output is correct
79 Correct 202 ms 444 KB Output is correct
80 Correct 197 ms 460 KB Output is correct
81 Correct 198 ms 424 KB Output is correct
82 Correct 138 ms 9644 KB Output is correct
83 Correct 550 ms 40104 KB Output is correct
84 Correct 40 ms 400 KB Output is correct
85 Correct 50 ms 412 KB Output is correct
86 Correct 131 ms 960 KB Output is correct
87 Correct 50 ms 396 KB Output is correct
88 Correct 42 ms 472 KB Output is correct
89 Correct 179 ms 432 KB Output is correct
90 Correct 211 ms 484 KB Output is correct
91 Runtime error 1 ms 468 KB Execution killed with signal 11
92 Halted 0 ms 0 KB -