Submission #397557

# Submission time Handle Problem Language Result Execution time Memory
397557 2021-05-02T11:39:47 Z phathnv IOI Fever (JOI21_fever) C++11
37 / 100
5000 ms 202180 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const int N = 1e5 + 7;
const int INF = 1e9 + 7;

int n, x[N], y[N], curInd, ind[N][4], dist[N * 4];
vector<pair<int, int>> adj[N * 4];

int Calc(int s){
    for(int i = 1; i <= 4 * n; i++)
        dist[i] = INF;
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
    dist[s] = 0;
    pq.push({0, s});
    while (!pq.empty()){
        int u = pq.top().second;
        int d = pq.top().first;
        pq.pop();
        if (dist[u] != d)
            continue;
        for(auto e : adj[u]){
            int v = e.first;
            int w = e.second;
            if (dist[u] <= w && dist[v] > w){
                dist[v] = w;
                pq.push({dist[v], v});
            }
        }
    }
    int res = 0;
    for(int i = 1; i <= n * 4; i++)
        res += (dist[i] != INF);
    return res;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> x[i] >> y[i];
        x[i] *= 2;
        y[i] *= 2;
        for(int dir = 0; dir < 4; dir++)
            ind[i][dir] = ++curInd;
    }
    for(int a = 1; a <= n; a++)
        for(int b = a + 1; b <= n; b++){
            int dx = abs(x[a] - x[b]);
            int dy = abs(y[a] - y[b]);
            int dist = (dx + dy) / 2;
            if (!dx){
                if (y[a] < y[b]){
                    adj[ind[a][0]].push_back({ind[b][2], dist});
                    adj[ind[b][2]].push_back({ind[a][0], dist});
                } else {
                    adj[ind[a][2]].push_back({ind[b][0], dist});
                    adj[ind[b][0]].push_back({ind[a][2], dist});
                }
            } else if (!dy){
                if (x[a] < x[b]){
                    adj[ind[a][1]].push_back({ind[b][3], dist});
                    adj[ind[b][3]].push_back({ind[a][1], dist});
                } else {
                    adj[ind[a][3]].push_back({ind[b][1], dist});
                    adj[ind[b][1]].push_back({ind[a][3], dist});
                }
            } else if (dx == dy){
                int dirA, dirB;
                dirA = (y[a] < y[b]? 0 : 2);
                dirB = (x[b] < x[a]? 1 : 3);
                adj[ind[a][dirA]].push_back({ind[b][dirB], dist});
                adj[ind[b][dirB]].push_back({ind[a][dirA], dist});
                swap(dirA, dirB);
                dirA = (dirA + 2) % 4;
                dirB = (dirB + 2) % 4;
                adj[ind[a][dirA]].push_back({ind[b][dirB], dist});
                adj[ind[b][dirB]].push_back({ind[a][dirA], dist});
            }
        }
    int res = 0;
    for(int dir = 0; dir < 4; dir++)
        res = max(res, Calc(ind[1][dir]));
    cout << res;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 9676 KB Output is correct
2 Correct 6 ms 9676 KB Output is correct
3 Correct 6 ms 9676 KB Output is correct
4 Correct 6 ms 9676 KB Output is correct
5 Correct 5 ms 9676 KB Output is correct
6 Correct 6 ms 9676 KB Output is correct
7 Correct 7 ms 9676 KB Output is correct
8 Correct 6 ms 9724 KB Output is correct
9 Correct 6 ms 9700 KB Output is correct
10 Correct 6 ms 9676 KB Output is correct
11 Correct 6 ms 9676 KB Output is correct
12 Correct 6 ms 9616 KB Output is correct
13 Correct 5 ms 9676 KB Output is correct
14 Correct 5 ms 9676 KB Output is correct
15 Correct 6 ms 9724 KB Output is correct
16 Correct 6 ms 9676 KB Output is correct
17 Correct 6 ms 9676 KB Output is correct
18 Correct 6 ms 9676 KB Output is correct
19 Correct 6 ms 9676 KB Output is correct
20 Correct 6 ms 9676 KB Output is correct
21 Correct 6 ms 9732 KB Output is correct
22 Correct 6 ms 9724 KB Output is correct
23 Correct 6 ms 9648 KB Output is correct
24 Correct 6 ms 9656 KB Output is correct
25 Correct 6 ms 9676 KB Output is correct
26 Correct 6 ms 9676 KB Output is correct
27 Correct 6 ms 9676 KB Output is correct
28 Correct 7 ms 9696 KB Output is correct
29 Correct 6 ms 9676 KB Output is correct
30 Correct 6 ms 9736 KB Output is correct
31 Correct 7 ms 9676 KB Output is correct
32 Correct 6 ms 9676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 9676 KB Output is correct
2 Correct 6 ms 9676 KB Output is correct
3 Correct 6 ms 9676 KB Output is correct
4 Correct 6 ms 9676 KB Output is correct
5 Correct 5 ms 9676 KB Output is correct
6 Correct 6 ms 9676 KB Output is correct
7 Correct 7 ms 9676 KB Output is correct
8 Correct 6 ms 9724 KB Output is correct
9 Correct 6 ms 9700 KB Output is correct
10 Correct 6 ms 9676 KB Output is correct
11 Correct 6 ms 9676 KB Output is correct
12 Correct 6 ms 9616 KB Output is correct
13 Correct 5 ms 9676 KB Output is correct
14 Correct 5 ms 9676 KB Output is correct
15 Correct 6 ms 9724 KB Output is correct
16 Correct 6 ms 9676 KB Output is correct
17 Correct 6 ms 9676 KB Output is correct
18 Correct 6 ms 9676 KB Output is correct
19 Correct 6 ms 9676 KB Output is correct
20 Correct 6 ms 9676 KB Output is correct
21 Correct 6 ms 9732 KB Output is correct
22 Correct 6 ms 9724 KB Output is correct
23 Correct 6 ms 9648 KB Output is correct
24 Correct 6 ms 9656 KB Output is correct
25 Correct 6 ms 9676 KB Output is correct
26 Correct 6 ms 9676 KB Output is correct
27 Correct 6 ms 9676 KB Output is correct
28 Correct 7 ms 9696 KB Output is correct
29 Correct 6 ms 9676 KB Output is correct
30 Correct 6 ms 9736 KB Output is correct
31 Correct 7 ms 9676 KB Output is correct
32 Correct 6 ms 9676 KB Output is correct
33 Correct 6 ms 9676 KB Output is correct
34 Correct 6 ms 9692 KB Output is correct
35 Correct 6 ms 9720 KB Output is correct
36 Correct 6 ms 9628 KB Output is correct
37 Correct 6 ms 9676 KB Output is correct
38 Correct 6 ms 9676 KB Output is correct
39 Correct 6 ms 9676 KB Output is correct
40 Correct 6 ms 9676 KB Output is correct
41 Correct 6 ms 9744 KB Output is correct
42 Correct 6 ms 9676 KB Output is correct
43 Correct 6 ms 9676 KB Output is correct
44 Correct 6 ms 9720 KB Output is correct
45 Correct 6 ms 9676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 9676 KB Output is correct
2 Correct 6 ms 9676 KB Output is correct
3 Correct 6 ms 9628 KB Output is correct
4 Correct 6 ms 9676 KB Output is correct
5 Correct 6 ms 9728 KB Output is correct
6 Correct 6 ms 9932 KB Output is correct
7 Correct 7 ms 9932 KB Output is correct
8 Correct 6 ms 9932 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 9676 KB Output is correct
2 Correct 6 ms 9676 KB Output is correct
3 Correct 6 ms 9676 KB Output is correct
4 Correct 6 ms 9676 KB Output is correct
5 Correct 5 ms 9676 KB Output is correct
6 Correct 6 ms 9676 KB Output is correct
7 Correct 7 ms 9676 KB Output is correct
8 Correct 6 ms 9724 KB Output is correct
9 Correct 6 ms 9700 KB Output is correct
10 Correct 6 ms 9676 KB Output is correct
11 Correct 6 ms 9676 KB Output is correct
12 Correct 6 ms 9616 KB Output is correct
13 Correct 5 ms 9676 KB Output is correct
14 Correct 5 ms 9676 KB Output is correct
15 Correct 6 ms 9724 KB Output is correct
16 Correct 6 ms 9676 KB Output is correct
17 Correct 6 ms 9676 KB Output is correct
18 Correct 6 ms 9676 KB Output is correct
19 Correct 6 ms 9676 KB Output is correct
20 Correct 6 ms 9676 KB Output is correct
21 Correct 6 ms 9732 KB Output is correct
22 Correct 6 ms 9724 KB Output is correct
23 Correct 6 ms 9648 KB Output is correct
24 Correct 6 ms 9656 KB Output is correct
25 Correct 6 ms 9676 KB Output is correct
26 Correct 6 ms 9676 KB Output is correct
27 Correct 6 ms 9676 KB Output is correct
28 Correct 7 ms 9696 KB Output is correct
29 Correct 6 ms 9676 KB Output is correct
30 Correct 6 ms 9736 KB Output is correct
31 Correct 7 ms 9676 KB Output is correct
32 Correct 6 ms 9676 KB Output is correct
33 Correct 6 ms 9676 KB Output is correct
34 Correct 6 ms 9692 KB Output is correct
35 Correct 6 ms 9720 KB Output is correct
36 Correct 6 ms 9628 KB Output is correct
37 Correct 6 ms 9676 KB Output is correct
38 Correct 6 ms 9676 KB Output is correct
39 Correct 6 ms 9676 KB Output is correct
40 Correct 6 ms 9676 KB Output is correct
41 Correct 6 ms 9744 KB Output is correct
42 Correct 6 ms 9676 KB Output is correct
43 Correct 6 ms 9676 KB Output is correct
44 Correct 6 ms 9720 KB Output is correct
45 Correct 6 ms 9676 KB Output is correct
46 Correct 6 ms 9676 KB Output is correct
47 Correct 6 ms 9676 KB Output is correct
48 Correct 6 ms 9628 KB Output is correct
49 Correct 6 ms 9676 KB Output is correct
50 Correct 6 ms 9728 KB Output is correct
51 Correct 6 ms 9932 KB Output is correct
52 Correct 7 ms 9932 KB Output is correct
53 Correct 6 ms 9932 KB Output is correct
54 Correct 5 ms 9652 KB Output is correct
55 Correct 6 ms 9720 KB Output is correct
56 Correct 6 ms 9652 KB Output is correct
57 Correct 6 ms 9724 KB Output is correct
58 Correct 6 ms 9980 KB Output is correct
59 Correct 7 ms 9724 KB Output is correct
60 Correct 6 ms 9676 KB Output is correct
61 Correct 6 ms 9676 KB Output is correct
62 Correct 6 ms 9676 KB Output is correct
63 Correct 6 ms 9720 KB Output is correct
64 Correct 6 ms 9676 KB Output is correct
65 Correct 6 ms 9676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 9676 KB Output is correct
2 Correct 6 ms 9676 KB Output is correct
3 Correct 6 ms 9676 KB Output is correct
4 Correct 6 ms 9676 KB Output is correct
5 Correct 5 ms 9676 KB Output is correct
6 Correct 6 ms 9676 KB Output is correct
7 Correct 7 ms 9676 KB Output is correct
8 Correct 6 ms 9724 KB Output is correct
9 Correct 6 ms 9700 KB Output is correct
10 Correct 6 ms 9676 KB Output is correct
11 Correct 6 ms 9676 KB Output is correct
12 Correct 6 ms 9616 KB Output is correct
13 Correct 5 ms 9676 KB Output is correct
14 Correct 5 ms 9676 KB Output is correct
15 Correct 6 ms 9724 KB Output is correct
16 Correct 6 ms 9676 KB Output is correct
17 Correct 6 ms 9676 KB Output is correct
18 Correct 6 ms 9676 KB Output is correct
19 Correct 6 ms 9676 KB Output is correct
20 Correct 6 ms 9676 KB Output is correct
21 Correct 6 ms 9732 KB Output is correct
22 Correct 6 ms 9724 KB Output is correct
23 Correct 6 ms 9648 KB Output is correct
24 Correct 6 ms 9656 KB Output is correct
25 Correct 6 ms 9676 KB Output is correct
26 Correct 6 ms 9676 KB Output is correct
27 Correct 6 ms 9676 KB Output is correct
28 Correct 7 ms 9696 KB Output is correct
29 Correct 6 ms 9676 KB Output is correct
30 Correct 6 ms 9736 KB Output is correct
31 Correct 7 ms 9676 KB Output is correct
32 Correct 6 ms 9676 KB Output is correct
33 Correct 6 ms 9676 KB Output is correct
34 Correct 6 ms 9692 KB Output is correct
35 Correct 6 ms 9720 KB Output is correct
36 Correct 6 ms 9628 KB Output is correct
37 Correct 6 ms 9676 KB Output is correct
38 Correct 6 ms 9676 KB Output is correct
39 Correct 6 ms 9676 KB Output is correct
40 Correct 6 ms 9676 KB Output is correct
41 Correct 6 ms 9744 KB Output is correct
42 Correct 6 ms 9676 KB Output is correct
43 Correct 6 ms 9676 KB Output is correct
44 Correct 6 ms 9720 KB Output is correct
45 Correct 6 ms 9676 KB Output is correct
46 Correct 6 ms 9676 KB Output is correct
47 Correct 6 ms 9676 KB Output is correct
48 Correct 6 ms 9628 KB Output is correct
49 Correct 6 ms 9676 KB Output is correct
50 Correct 6 ms 9728 KB Output is correct
51 Correct 6 ms 9932 KB Output is correct
52 Correct 7 ms 9932 KB Output is correct
53 Correct 6 ms 9932 KB Output is correct
54 Correct 5 ms 9652 KB Output is correct
55 Correct 6 ms 9720 KB Output is correct
56 Correct 6 ms 9652 KB Output is correct
57 Correct 6 ms 9724 KB Output is correct
58 Correct 6 ms 9980 KB Output is correct
59 Correct 7 ms 9724 KB Output is correct
60 Correct 6 ms 9676 KB Output is correct
61 Correct 6 ms 9676 KB Output is correct
62 Correct 6 ms 9676 KB Output is correct
63 Correct 6 ms 9720 KB Output is correct
64 Correct 6 ms 9676 KB Output is correct
65 Correct 6 ms 9676 KB Output is correct
66 Correct 20 ms 9960 KB Output is correct
67 Correct 20 ms 9964 KB Output is correct
68 Correct 20 ms 9876 KB Output is correct
69 Correct 44 ms 15280 KB Output is correct
70 Correct 28 ms 11760 KB Output is correct
71 Correct 24 ms 10976 KB Output is correct
72 Correct 20 ms 10028 KB Output is correct
73 Correct 24 ms 9924 KB Output is correct
74 Correct 470 ms 202180 KB Output is correct
75 Correct 501 ms 202180 KB Output is correct
76 Correct 34 ms 15428 KB Output is correct
77 Correct 53 ms 22652 KB Output is correct
78 Correct 33 ms 15052 KB Output is correct
79 Correct 42 ms 16032 KB Output is correct
80 Correct 20 ms 9872 KB Output is correct
81 Correct 20 ms 9932 KB Output is correct
82 Correct 222 ms 109164 KB Output is correct
83 Correct 231 ms 109136 KB Output is correct
84 Correct 106 ms 59588 KB Output is correct
85 Correct 43 ms 19752 KB Output is correct
86 Correct 46 ms 18472 KB Output is correct
87 Correct 60 ms 35276 KB Output is correct
88 Correct 426 ms 196732 KB Output is correct
89 Correct 20 ms 10092 KB Output is correct
90 Correct 20 ms 10136 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 9676 KB Output is correct
2 Correct 6 ms 9676 KB Output is correct
3 Correct 6 ms 9676 KB Output is correct
4 Correct 6 ms 9676 KB Output is correct
5 Correct 5 ms 9676 KB Output is correct
6 Correct 6 ms 9676 KB Output is correct
7 Correct 7 ms 9676 KB Output is correct
8 Correct 6 ms 9724 KB Output is correct
9 Correct 6 ms 9700 KB Output is correct
10 Correct 6 ms 9676 KB Output is correct
11 Correct 6 ms 9676 KB Output is correct
12 Correct 6 ms 9616 KB Output is correct
13 Correct 5 ms 9676 KB Output is correct
14 Correct 5 ms 9676 KB Output is correct
15 Correct 6 ms 9724 KB Output is correct
16 Correct 6 ms 9676 KB Output is correct
17 Correct 6 ms 9676 KB Output is correct
18 Correct 6 ms 9676 KB Output is correct
19 Correct 6 ms 9676 KB Output is correct
20 Correct 6 ms 9676 KB Output is correct
21 Correct 6 ms 9732 KB Output is correct
22 Correct 6 ms 9724 KB Output is correct
23 Correct 6 ms 9648 KB Output is correct
24 Correct 6 ms 9656 KB Output is correct
25 Correct 6 ms 9676 KB Output is correct
26 Correct 6 ms 9676 KB Output is correct
27 Correct 6 ms 9676 KB Output is correct
28 Correct 7 ms 9696 KB Output is correct
29 Correct 6 ms 9676 KB Output is correct
30 Correct 6 ms 9736 KB Output is correct
31 Correct 7 ms 9676 KB Output is correct
32 Correct 6 ms 9676 KB Output is correct
33 Correct 6 ms 9676 KB Output is correct
34 Correct 6 ms 9692 KB Output is correct
35 Correct 6 ms 9720 KB Output is correct
36 Correct 6 ms 9628 KB Output is correct
37 Correct 6 ms 9676 KB Output is correct
38 Correct 6 ms 9676 KB Output is correct
39 Correct 6 ms 9676 KB Output is correct
40 Correct 6 ms 9676 KB Output is correct
41 Correct 6 ms 9744 KB Output is correct
42 Correct 6 ms 9676 KB Output is correct
43 Correct 6 ms 9676 KB Output is correct
44 Correct 6 ms 9720 KB Output is correct
45 Correct 6 ms 9676 KB Output is correct
46 Correct 6 ms 9676 KB Output is correct
47 Correct 6 ms 9676 KB Output is correct
48 Correct 6 ms 9628 KB Output is correct
49 Correct 6 ms 9676 KB Output is correct
50 Correct 6 ms 9728 KB Output is correct
51 Correct 6 ms 9932 KB Output is correct
52 Correct 7 ms 9932 KB Output is correct
53 Correct 6 ms 9932 KB Output is correct
54 Correct 5 ms 9652 KB Output is correct
55 Correct 6 ms 9720 KB Output is correct
56 Correct 6 ms 9652 KB Output is correct
57 Correct 6 ms 9724 KB Output is correct
58 Correct 6 ms 9980 KB Output is correct
59 Correct 7 ms 9724 KB Output is correct
60 Correct 6 ms 9676 KB Output is correct
61 Correct 6 ms 9676 KB Output is correct
62 Correct 6 ms 9676 KB Output is correct
63 Correct 6 ms 9720 KB Output is correct
64 Correct 6 ms 9676 KB Output is correct
65 Correct 6 ms 9676 KB Output is correct
66 Execution timed out 5056 ms 15456 KB Time limit exceeded
67 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 9676 KB Output is correct
2 Correct 6 ms 9676 KB Output is correct
3 Correct 6 ms 9676 KB Output is correct
4 Correct 6 ms 9676 KB Output is correct
5 Correct 5 ms 9676 KB Output is correct
6 Correct 6 ms 9676 KB Output is correct
7 Correct 7 ms 9676 KB Output is correct
8 Correct 6 ms 9724 KB Output is correct
9 Correct 6 ms 9700 KB Output is correct
10 Correct 6 ms 9676 KB Output is correct
11 Correct 6 ms 9676 KB Output is correct
12 Correct 6 ms 9616 KB Output is correct
13 Correct 5 ms 9676 KB Output is correct
14 Correct 5 ms 9676 KB Output is correct
15 Correct 6 ms 9724 KB Output is correct
16 Correct 6 ms 9676 KB Output is correct
17 Correct 6 ms 9676 KB Output is correct
18 Correct 6 ms 9676 KB Output is correct
19 Correct 6 ms 9676 KB Output is correct
20 Correct 6 ms 9676 KB Output is correct
21 Correct 6 ms 9732 KB Output is correct
22 Correct 6 ms 9724 KB Output is correct
23 Correct 6 ms 9648 KB Output is correct
24 Correct 6 ms 9656 KB Output is correct
25 Correct 6 ms 9676 KB Output is correct
26 Correct 6 ms 9676 KB Output is correct
27 Correct 6 ms 9676 KB Output is correct
28 Correct 7 ms 9696 KB Output is correct
29 Correct 6 ms 9676 KB Output is correct
30 Correct 6 ms 9736 KB Output is correct
31 Correct 7 ms 9676 KB Output is correct
32 Correct 6 ms 9676 KB Output is correct
33 Correct 6 ms 9676 KB Output is correct
34 Correct 6 ms 9692 KB Output is correct
35 Correct 6 ms 9720 KB Output is correct
36 Correct 6 ms 9628 KB Output is correct
37 Correct 6 ms 9676 KB Output is correct
38 Correct 6 ms 9676 KB Output is correct
39 Correct 6 ms 9676 KB Output is correct
40 Correct 6 ms 9676 KB Output is correct
41 Correct 6 ms 9744 KB Output is correct
42 Correct 6 ms 9676 KB Output is correct
43 Correct 6 ms 9676 KB Output is correct
44 Correct 6 ms 9720 KB Output is correct
45 Correct 6 ms 9676 KB Output is correct
46 Correct 6 ms 9676 KB Output is correct
47 Correct 6 ms 9676 KB Output is correct
48 Correct 6 ms 9628 KB Output is correct
49 Correct 6 ms 9676 KB Output is correct
50 Correct 6 ms 9728 KB Output is correct
51 Correct 6 ms 9932 KB Output is correct
52 Correct 7 ms 9932 KB Output is correct
53 Correct 6 ms 9932 KB Output is correct
54 Correct 5 ms 9652 KB Output is correct
55 Correct 6 ms 9720 KB Output is correct
56 Correct 6 ms 9652 KB Output is correct
57 Correct 6 ms 9724 KB Output is correct
58 Correct 6 ms 9980 KB Output is correct
59 Correct 7 ms 9724 KB Output is correct
60 Correct 6 ms 9676 KB Output is correct
61 Correct 6 ms 9676 KB Output is correct
62 Correct 6 ms 9676 KB Output is correct
63 Correct 6 ms 9720 KB Output is correct
64 Correct 6 ms 9676 KB Output is correct
65 Correct 6 ms 9676 KB Output is correct
66 Correct 20 ms 9960 KB Output is correct
67 Correct 20 ms 9964 KB Output is correct
68 Correct 20 ms 9876 KB Output is correct
69 Correct 44 ms 15280 KB Output is correct
70 Correct 28 ms 11760 KB Output is correct
71 Correct 24 ms 10976 KB Output is correct
72 Correct 20 ms 10028 KB Output is correct
73 Correct 24 ms 9924 KB Output is correct
74 Correct 470 ms 202180 KB Output is correct
75 Correct 501 ms 202180 KB Output is correct
76 Correct 34 ms 15428 KB Output is correct
77 Correct 53 ms 22652 KB Output is correct
78 Correct 33 ms 15052 KB Output is correct
79 Correct 42 ms 16032 KB Output is correct
80 Correct 20 ms 9872 KB Output is correct
81 Correct 20 ms 9932 KB Output is correct
82 Correct 222 ms 109164 KB Output is correct
83 Correct 231 ms 109136 KB Output is correct
84 Correct 106 ms 59588 KB Output is correct
85 Correct 43 ms 19752 KB Output is correct
86 Correct 46 ms 18472 KB Output is correct
87 Correct 60 ms 35276 KB Output is correct
88 Correct 426 ms 196732 KB Output is correct
89 Correct 20 ms 10092 KB Output is correct
90 Correct 20 ms 10136 KB Output is correct
91 Execution timed out 5056 ms 15456 KB Time limit exceeded
92 Halted 0 ms 0 KB -