Submission #829467

# Submission time Handle Problem Language Result Execution time Memory
829467 2023-08-18T11:05:30 Z Abrar_Al_Samit Fountain Parks (IOI21_parks) C++17
15 / 100
643 ms 46036 KB
#include <bits/stdc++.h>
#include "parks.h"
using namespace std;

const int nax = 200000;
vector<int>g[nax];
bool vis[nax];

void trav(int v) {
    vis[v] = 1;
    for(int u : g[v]) if(!vis[u]) {
        trav(u);
    }
}
int construct_roads(vector<int> x, vector<int> y) {
    int n = x.size();
    map<pair<int,int>, int>ft;
    for(int i=0; i<n; ++i) {
        ft[{x[i], y[i]}] = i;
    }

    int dx[] = {2, -2, 0, 0};
    int dy[] = {0, 0, 2, -2};

    vector<int>u, v, a, b;

    for(int i=0; i<n; ++i) {
        for(int j=0; j<4; ++j) {
            int nx = x[i] + dx[j], ny = y[i] + dy[j];
            if(ft.count(make_pair(nx, ny))) {
                g[i].push_back(ft[{nx, ny}]);

                if(i < ft[{nx, ny}]) {
                    u.push_back(i);
                    v.push_back(ft[{nx, ny}]);

                    if(j < 2) { //horizontal
                        a.push_back(x[i] + nx >> 1);
                        b.push_back(ny - 1);
                    } else { //vertical
                        if(x[i]==2) {
                            a.push_back(x[i] - 1);
                            b.push_back(y[i] + ny >> 1);
                        } else {
                            a.push_back(x[i] + 1);
                            b.push_back(y[i] + ny >> 1);
                        }
                    }
                }
            }
        }
    }
    trav(0);
    for(int i=0; i<n; ++i) if(!vis[i]) {
        return 0;
    }

    build(u, v, a, b);
    return 1;
}

Compilation message

parks.cpp: In function 'int construct_roads(std::vector<int>, std::vector<int>)':
parks.cpp:38:42: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   38 |                         a.push_back(x[i] + nx >> 1);
parks.cpp:43:46: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   43 |                             b.push_back(y[i] + ny >> 1);
parks.cpp:46:46: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   46 |                             b.push_back(y[i] + ny >> 1);
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 2 ms 4948 KB Output is correct
3 Correct 2 ms 4948 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 2 ms 4948 KB Output is correct
6 Correct 2 ms 4948 KB Output is correct
7 Correct 2 ms 4948 KB Output is correct
8 Correct 2 ms 4884 KB Output is correct
9 Correct 173 ms 23116 KB Output is correct
10 Correct 16 ms 6936 KB Output is correct
11 Correct 74 ms 14752 KB Output is correct
12 Correct 19 ms 8004 KB Output is correct
13 Correct 51 ms 11412 KB Output is correct
14 Correct 3 ms 5076 KB Output is correct
15 Correct 4 ms 5204 KB Output is correct
16 Correct 184 ms 22392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 2 ms 4948 KB Output is correct
3 Correct 2 ms 4948 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 2 ms 4948 KB Output is correct
6 Correct 2 ms 4948 KB Output is correct
7 Correct 2 ms 4948 KB Output is correct
8 Correct 2 ms 4884 KB Output is correct
9 Correct 173 ms 23116 KB Output is correct
10 Correct 16 ms 6936 KB Output is correct
11 Correct 74 ms 14752 KB Output is correct
12 Correct 19 ms 8004 KB Output is correct
13 Correct 51 ms 11412 KB Output is correct
14 Correct 3 ms 5076 KB Output is correct
15 Correct 4 ms 5204 KB Output is correct
16 Correct 184 ms 22392 KB Output is correct
17 Correct 2 ms 4948 KB Output is correct
18 Correct 2 ms 4948 KB Output is correct
19 Correct 2 ms 4948 KB Output is correct
20 Correct 2 ms 4948 KB Output is correct
21 Correct 2 ms 4948 KB Output is correct
22 Correct 2 ms 4948 KB Output is correct
23 Correct 593 ms 46036 KB Output is correct
24 Correct 3 ms 5076 KB Output is correct
25 Correct 4 ms 5204 KB Output is correct
26 Correct 6 ms 5460 KB Output is correct
27 Correct 7 ms 5584 KB Output is correct
28 Correct 179 ms 21420 KB Output is correct
29 Correct 301 ms 29256 KB Output is correct
30 Correct 407 ms 37884 KB Output is correct
31 Correct 538 ms 45620 KB Output is correct
32 Correct 2 ms 4948 KB Output is correct
33 Correct 4 ms 4984 KB Output is correct
34 Correct 2 ms 4948 KB Output is correct
35 Correct 2 ms 4948 KB Output is correct
36 Correct 2 ms 4948 KB Output is correct
37 Correct 2 ms 4924 KB Output is correct
38 Correct 2 ms 4948 KB Output is correct
39 Correct 2 ms 4948 KB Output is correct
40 Correct 2 ms 4948 KB Output is correct
41 Correct 3 ms 5000 KB Output is correct
42 Correct 2 ms 5000 KB Output is correct
43 Correct 4 ms 5204 KB Output is correct
44 Correct 5 ms 5400 KB Output is correct
45 Correct 196 ms 22700 KB Output is correct
46 Correct 329 ms 30700 KB Output is correct
47 Correct 343 ms 30520 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 2 ms 4948 KB Output is correct
3 Correct 2 ms 4948 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 2 ms 4948 KB Output is correct
6 Correct 2 ms 4948 KB Output is correct
7 Correct 2 ms 4948 KB Output is correct
8 Correct 2 ms 4884 KB Output is correct
9 Correct 173 ms 23116 KB Output is correct
10 Correct 16 ms 6936 KB Output is correct
11 Correct 74 ms 14752 KB Output is correct
12 Correct 19 ms 8004 KB Output is correct
13 Correct 51 ms 11412 KB Output is correct
14 Correct 3 ms 5076 KB Output is correct
15 Correct 4 ms 5204 KB Output is correct
16 Correct 184 ms 22392 KB Output is correct
17 Correct 2 ms 4948 KB Output is correct
18 Correct 2 ms 4948 KB Output is correct
19 Correct 2 ms 4948 KB Output is correct
20 Correct 2 ms 4948 KB Output is correct
21 Correct 2 ms 4948 KB Output is correct
22 Correct 2 ms 4948 KB Output is correct
23 Correct 593 ms 46036 KB Output is correct
24 Correct 3 ms 5076 KB Output is correct
25 Correct 4 ms 5204 KB Output is correct
26 Correct 6 ms 5460 KB Output is correct
27 Correct 7 ms 5584 KB Output is correct
28 Correct 179 ms 21420 KB Output is correct
29 Correct 301 ms 29256 KB Output is correct
30 Correct 407 ms 37884 KB Output is correct
31 Correct 538 ms 45620 KB Output is correct
32 Correct 2 ms 4948 KB Output is correct
33 Correct 4 ms 4984 KB Output is correct
34 Correct 2 ms 4948 KB Output is correct
35 Correct 2 ms 4948 KB Output is correct
36 Correct 2 ms 4948 KB Output is correct
37 Correct 2 ms 4924 KB Output is correct
38 Correct 2 ms 4948 KB Output is correct
39 Correct 2 ms 4948 KB Output is correct
40 Correct 2 ms 4948 KB Output is correct
41 Correct 3 ms 5000 KB Output is correct
42 Correct 2 ms 5000 KB Output is correct
43 Correct 4 ms 5204 KB Output is correct
44 Correct 5 ms 5400 KB Output is correct
45 Correct 196 ms 22700 KB Output is correct
46 Correct 329 ms 30700 KB Output is correct
47 Correct 343 ms 30520 KB Output is correct
48 Incorrect 2 ms 4948 KB Tree @(5, 3) appears more than once: for edges on positions 2 and 3
49 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 2 ms 4948 KB Output is correct
3 Correct 2 ms 4948 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 2 ms 4948 KB Output is correct
6 Correct 2 ms 4948 KB Output is correct
7 Correct 2 ms 4948 KB Output is correct
8 Correct 2 ms 4884 KB Output is correct
9 Correct 173 ms 23116 KB Output is correct
10 Correct 16 ms 6936 KB Output is correct
11 Correct 74 ms 14752 KB Output is correct
12 Correct 19 ms 8004 KB Output is correct
13 Correct 51 ms 11412 KB Output is correct
14 Correct 3 ms 5076 KB Output is correct
15 Correct 4 ms 5204 KB Output is correct
16 Correct 184 ms 22392 KB Output is correct
17 Correct 3 ms 4948 KB Output is correct
18 Correct 2 ms 4948 KB Output is correct
19 Correct 2 ms 5004 KB Output is correct
20 Correct 643 ms 42452 KB Output is correct
21 Incorrect 570 ms 41476 KB Tree @(56859, 56863) appears more than once: for edges on positions 0 and 1
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 2 ms 4948 KB Output is correct
3 Correct 2 ms 4948 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 2 ms 4948 KB Output is correct
6 Correct 2 ms 4948 KB Output is correct
7 Correct 2 ms 4948 KB Output is correct
8 Correct 2 ms 4884 KB Output is correct
9 Correct 173 ms 23116 KB Output is correct
10 Correct 16 ms 6936 KB Output is correct
11 Correct 74 ms 14752 KB Output is correct
12 Correct 19 ms 8004 KB Output is correct
13 Correct 51 ms 11412 KB Output is correct
14 Correct 3 ms 5076 KB Output is correct
15 Correct 4 ms 5204 KB Output is correct
16 Correct 184 ms 22392 KB Output is correct
17 Correct 556 ms 41980 KB Output is correct
18 Incorrect 470 ms 40780 KB Tree @(50003, 100001) appears more than once: for edges on positions 157198 and 161590
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 2 ms 4948 KB Output is correct
3 Correct 2 ms 4948 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 2 ms 4948 KB Output is correct
6 Correct 2 ms 4948 KB Output is correct
7 Correct 2 ms 4948 KB Output is correct
8 Correct 2 ms 4884 KB Output is correct
9 Correct 173 ms 23116 KB Output is correct
10 Correct 16 ms 6936 KB Output is correct
11 Correct 74 ms 14752 KB Output is correct
12 Correct 19 ms 8004 KB Output is correct
13 Correct 51 ms 11412 KB Output is correct
14 Correct 3 ms 5076 KB Output is correct
15 Correct 4 ms 5204 KB Output is correct
16 Correct 184 ms 22392 KB Output is correct
17 Correct 2 ms 4948 KB Output is correct
18 Correct 2 ms 4948 KB Output is correct
19 Correct 2 ms 4948 KB Output is correct
20 Correct 2 ms 4948 KB Output is correct
21 Correct 2 ms 4948 KB Output is correct
22 Correct 2 ms 4948 KB Output is correct
23 Correct 593 ms 46036 KB Output is correct
24 Correct 3 ms 5076 KB Output is correct
25 Correct 4 ms 5204 KB Output is correct
26 Correct 6 ms 5460 KB Output is correct
27 Correct 7 ms 5584 KB Output is correct
28 Correct 179 ms 21420 KB Output is correct
29 Correct 301 ms 29256 KB Output is correct
30 Correct 407 ms 37884 KB Output is correct
31 Correct 538 ms 45620 KB Output is correct
32 Correct 2 ms 4948 KB Output is correct
33 Correct 4 ms 4984 KB Output is correct
34 Correct 2 ms 4948 KB Output is correct
35 Correct 2 ms 4948 KB Output is correct
36 Correct 2 ms 4948 KB Output is correct
37 Correct 2 ms 4924 KB Output is correct
38 Correct 2 ms 4948 KB Output is correct
39 Correct 2 ms 4948 KB Output is correct
40 Correct 2 ms 4948 KB Output is correct
41 Correct 3 ms 5000 KB Output is correct
42 Correct 2 ms 5000 KB Output is correct
43 Correct 4 ms 5204 KB Output is correct
44 Correct 5 ms 5400 KB Output is correct
45 Correct 196 ms 22700 KB Output is correct
46 Correct 329 ms 30700 KB Output is correct
47 Correct 343 ms 30520 KB Output is correct
48 Incorrect 2 ms 4948 KB Tree @(5, 3) appears more than once: for edges on positions 2 and 3
49 Halted 0 ms 0 KB -