답안 #826239

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
826239 2023-08-15T11:26:24 Z loctildore 분수 공원 (IOI21_parks) C++17
70 / 100
506 ms 71780 KB
#include "parks.h"
#include <bits/stdc++.h>
using namespace std;
// trans rights
#define ll long long
#define f first
#define s second
#define endl '\n'
#define all(x) begin(x), end(x)
int n;
vector<int> u, v, a, b;
map<pair<int, int>, int> mp;
set<pair<int, int>> done;

vector<pair<int, int>> dirs = {{0, 2}, {2, 0}, {0, -2}, {-2, 0}};
vector<pair<int, int>> bloc[2] = {{{-1, 1}, {1, 1}, {1, -1}, {-1, -1}}, {{1, 1}, {1, -1}, {-1, -1}, {-1, 1}}};

void dfs(int x, int y, int ldir = 0) {
    done.insert({x, y});
    for (int i = 0; i < 4; i++) {
        int ndir = (ldir + 3 + i) % 4;
        int nx = x + dirs[ndir].f;
        int ny = y + dirs[ndir].s;
        if (mp.find({nx, ny}) == mp.end()) continue;
        if (done.find({nx, ny}) != done.end()) continue;

        int tx = x + bloc[0][ndir].f;
        int ty = y + bloc[0][ndir].s;
        if (done.find({tx, ty}) == done.end()) {
            u.push_back(mp[{x, y}]);
            v.push_back(mp[{nx, ny}]);
            done.insert({tx, ty});
            a.push_back(tx);
            b.push_back(ty);
            dfs(nx, ny, ndir);
            continue;
        }

        tx = x + bloc[1][ndir].f;
        ty = y + bloc[1][ndir].s;
        if (done.find({tx, ty}) == done.end()) {
            u.push_back(mp[{x, y}]);
            v.push_back(mp[{nx, ny}]);
            done.insert({tx, ty});
            a.push_back(tx);
            b.push_back(ty);
            dfs(nx, ny, ndir);
        }
    }
}

int construct_roads(vector<int> xs, vector<int> ys) {
    n = xs.size();
    for (int i = 0; i < n; i++) {
        mp[{xs[i], ys[i]}] = i;
    }
    dfs(xs[0], ys[0]);
    if (u.size() == n - 1) {
        build(u, v, a, b);
        return 1;
    }
    return 0;
}

Compilation message

parks.cpp: In function 'int construct_roads(std::vector<int>, std::vector<int>)':
parks.cpp:58:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   58 |     if (u.size() == n - 1) {
      |         ~~~~~~~~~^~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 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 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 166 ms 34536 KB Output is correct
10 Correct 14 ms 3924 KB Output is correct
11 Correct 90 ms 19212 KB Output is correct
12 Correct 22 ms 5764 KB Output is correct
13 Correct 43 ms 11248 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 170 ms 29416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 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 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 166 ms 34536 KB Output is correct
10 Correct 14 ms 3924 KB Output is correct
11 Correct 90 ms 19212 KB Output is correct
12 Correct 22 ms 5764 KB Output is correct
13 Correct 43 ms 11248 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 170 ms 29416 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 296 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 435 ms 68036 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 2 ms 724 KB Output is correct
26 Correct 2 ms 860 KB Output is correct
27 Correct 2 ms 696 KB Output is correct
28 Correct 154 ms 28492 KB Output is correct
29 Correct 247 ms 42644 KB Output is correct
30 Correct 351 ms 56696 KB Output is correct
31 Correct 443 ms 65796 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 0 ms 212 KB Output is correct
37 Correct 0 ms 212 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Correct 0 ms 212 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 2 ms 596 KB Output is correct
44 Correct 2 ms 568 KB Output is correct
45 Correct 181 ms 30728 KB Output is correct
46 Correct 301 ms 45212 KB Output is correct
47 Correct 271 ms 44448 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 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 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 166 ms 34536 KB Output is correct
10 Correct 14 ms 3924 KB Output is correct
11 Correct 90 ms 19212 KB Output is correct
12 Correct 22 ms 5764 KB Output is correct
13 Correct 43 ms 11248 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 170 ms 29416 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 296 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 435 ms 68036 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 2 ms 724 KB Output is correct
26 Correct 2 ms 860 KB Output is correct
27 Correct 2 ms 696 KB Output is correct
28 Correct 154 ms 28492 KB Output is correct
29 Correct 247 ms 42644 KB Output is correct
30 Correct 351 ms 56696 KB Output is correct
31 Correct 443 ms 65796 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 0 ms 212 KB Output is correct
37 Correct 0 ms 212 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Correct 0 ms 212 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 2 ms 596 KB Output is correct
44 Correct 2 ms 568 KB Output is correct
45 Correct 181 ms 30728 KB Output is correct
46 Correct 301 ms 45212 KB Output is correct
47 Correct 271 ms 44448 KB Output is correct
48 Correct 0 ms 300 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 0 ms 212 KB Output is correct
51 Correct 0 ms 212 KB Output is correct
52 Correct 1 ms 212 KB Output is correct
53 Correct 1 ms 212 KB Output is correct
54 Correct 1 ms 212 KB Output is correct
55 Correct 456 ms 64868 KB Output is correct
56 Correct 0 ms 212 KB Output is correct
57 Correct 3 ms 852 KB Output is correct
58 Correct 10 ms 2360 KB Output is correct
59 Correct 5 ms 1620 KB Output is correct
60 Correct 209 ms 35208 KB Output is correct
61 Correct 307 ms 45952 KB Output is correct
62 Correct 366 ms 53408 KB Output is correct
63 Correct 485 ms 68120 KB Output is correct
64 Correct 0 ms 212 KB Output is correct
65 Correct 0 ms 212 KB Output is correct
66 Correct 0 ms 212 KB Output is correct
67 Correct 389 ms 63588 KB Output is correct
68 Correct 404 ms 63928 KB Output is correct
69 Correct 391 ms 66396 KB Output is correct
70 Correct 3 ms 852 KB Output is correct
71 Correct 4 ms 1236 KB Output is correct
72 Correct 185 ms 27164 KB Output is correct
73 Correct 316 ms 43916 KB Output is correct
74 Correct 431 ms 54396 KB Output is correct
75 Correct 412 ms 65792 KB Output is correct
76 Correct 405 ms 70792 KB Output is correct
77 Correct 5 ms 1108 KB Output is correct
78 Correct 6 ms 1620 KB Output is correct
79 Correct 185 ms 28124 KB Output is correct
80 Correct 301 ms 42648 KB Output is correct
81 Correct 410 ms 57060 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 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 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 166 ms 34536 KB Output is correct
10 Correct 14 ms 3924 KB Output is correct
11 Correct 90 ms 19212 KB Output is correct
12 Correct 22 ms 5764 KB Output is correct
13 Correct 43 ms 11248 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 170 ms 29416 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 423 ms 71220 KB Output is correct
21 Correct 412 ms 66264 KB Output is correct
22 Correct 415 ms 63484 KB Output is correct
23 Correct 347 ms 52852 KB Output is correct
24 Correct 94 ms 17616 KB Output is correct
25 Correct 99 ms 17608 KB Output is correct
26 Correct 101 ms 17588 KB Output is correct
27 Correct 327 ms 45984 KB Output is correct
28 Correct 306 ms 45840 KB Output is correct
29 Correct 462 ms 45616 KB Output is correct
30 Correct 454 ms 45876 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 29 ms 4680 KB Output is correct
33 Correct 45 ms 9272 KB Output is correct
34 Correct 381 ms 67564 KB Output is correct
35 Correct 8 ms 1680 KB Output is correct
36 Correct 31 ms 5944 KB Output is correct
37 Correct 60 ms 10592 KB Output is correct
38 Correct 167 ms 19120 KB Output is correct
39 Correct 209 ms 25964 KB Output is correct
40 Correct 279 ms 33084 KB Output is correct
41 Correct 321 ms 40240 KB Output is correct
42 Correct 392 ms 47244 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 1 ms 296 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 0 ms 300 KB Output is correct
47 Correct 0 ms 296 KB Output is correct
48 Correct 0 ms 304 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 0 ms 212 KB Output is correct
51 Correct 0 ms 212 KB Output is correct
52 Correct 0 ms 212 KB Output is correct
53 Correct 1 ms 212 KB Output is correct
54 Correct 2 ms 596 KB Output is correct
55 Correct 2 ms 596 KB Output is correct
56 Correct 188 ms 30764 KB Output is correct
57 Correct 268 ms 45196 KB Output is correct
58 Correct 320 ms 44408 KB Output is correct
59 Correct 0 ms 212 KB Output is correct
60 Correct 0 ms 212 KB Output is correct
61 Correct 0 ms 212 KB Output is correct
62 Correct 389 ms 63620 KB Output is correct
63 Correct 403 ms 63904 KB Output is correct
64 Correct 380 ms 66476 KB Output is correct
65 Correct 3 ms 980 KB Output is correct
66 Correct 4 ms 1236 KB Output is correct
67 Correct 187 ms 27084 KB Output is correct
68 Correct 285 ms 43744 KB Output is correct
69 Correct 453 ms 54400 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 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 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 166 ms 34536 KB Output is correct
10 Correct 14 ms 3924 KB Output is correct
11 Correct 90 ms 19212 KB Output is correct
12 Correct 22 ms 5764 KB Output is correct
13 Correct 43 ms 11248 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 170 ms 29416 KB Output is correct
17 Correct 420 ms 71136 KB Output is correct
18 Correct 400 ms 69036 KB Output is correct
19 Correct 431 ms 71780 KB Output is correct
20 Correct 506 ms 61072 KB Output is correct
21 Correct 382 ms 52436 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 53 ms 8780 KB Output is correct
24 Correct 19 ms 4052 KB Output is correct
25 Correct 45 ms 8760 KB Output is correct
26 Correct 70 ms 13352 KB Output is correct
27 Correct 223 ms 31464 KB Output is correct
28 Correct 272 ms 39824 KB Output is correct
29 Correct 342 ms 47964 KB Output is correct
30 Correct 413 ms 55228 KB Output is correct
31 Correct 490 ms 63536 KB Output is correct
32 Correct 417 ms 65776 KB Output is correct
33 Correct 394 ms 70868 KB Output is correct
34 Correct 5 ms 1108 KB Output is correct
35 Correct 6 ms 1620 KB Output is correct
36 Correct 175 ms 28008 KB Output is correct
37 Correct 287 ms 42656 KB Output is correct
38 Correct 417 ms 56940 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 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 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 166 ms 34536 KB Output is correct
10 Correct 14 ms 3924 KB Output is correct
11 Correct 90 ms 19212 KB Output is correct
12 Correct 22 ms 5764 KB Output is correct
13 Correct 43 ms 11248 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 170 ms 29416 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 296 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 435 ms 68036 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 2 ms 724 KB Output is correct
26 Correct 2 ms 860 KB Output is correct
27 Correct 2 ms 696 KB Output is correct
28 Correct 154 ms 28492 KB Output is correct
29 Correct 247 ms 42644 KB Output is correct
30 Correct 351 ms 56696 KB Output is correct
31 Correct 443 ms 65796 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 0 ms 212 KB Output is correct
37 Correct 0 ms 212 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Correct 0 ms 212 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 2 ms 596 KB Output is correct
44 Correct 2 ms 568 KB Output is correct
45 Correct 181 ms 30728 KB Output is correct
46 Correct 301 ms 45212 KB Output is correct
47 Correct 271 ms 44448 KB Output is correct
48 Correct 0 ms 300 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 0 ms 212 KB Output is correct
51 Correct 0 ms 212 KB Output is correct
52 Correct 1 ms 212 KB Output is correct
53 Correct 1 ms 212 KB Output is correct
54 Correct 1 ms 212 KB Output is correct
55 Correct 456 ms 64868 KB Output is correct
56 Correct 0 ms 212 KB Output is correct
57 Correct 3 ms 852 KB Output is correct
58 Correct 10 ms 2360 KB Output is correct
59 Correct 5 ms 1620 KB Output is correct
60 Correct 209 ms 35208 KB Output is correct
61 Correct 307 ms 45952 KB Output is correct
62 Correct 366 ms 53408 KB Output is correct
63 Correct 485 ms 68120 KB Output is correct
64 Correct 0 ms 212 KB Output is correct
65 Correct 0 ms 212 KB Output is correct
66 Correct 0 ms 212 KB Output is correct
67 Correct 389 ms 63588 KB Output is correct
68 Correct 404 ms 63928 KB Output is correct
69 Correct 391 ms 66396 KB Output is correct
70 Correct 3 ms 852 KB Output is correct
71 Correct 4 ms 1236 KB Output is correct
72 Correct 185 ms 27164 KB Output is correct
73 Correct 316 ms 43916 KB Output is correct
74 Correct 431 ms 54396 KB Output is correct
75 Correct 412 ms 65792 KB Output is correct
76 Correct 405 ms 70792 KB Output is correct
77 Correct 5 ms 1108 KB Output is correct
78 Correct 6 ms 1620 KB Output is correct
79 Correct 185 ms 28124 KB Output is correct
80 Correct 301 ms 42648 KB Output is correct
81 Correct 410 ms 57060 KB Output is correct
82 Correct 1 ms 212 KB Output is correct
83 Correct 0 ms 212 KB Output is correct
84 Correct 0 ms 212 KB Output is correct
85 Correct 423 ms 71220 KB Output is correct
86 Correct 412 ms 66264 KB Output is correct
87 Correct 415 ms 63484 KB Output is correct
88 Correct 347 ms 52852 KB Output is correct
89 Correct 94 ms 17616 KB Output is correct
90 Correct 99 ms 17608 KB Output is correct
91 Correct 101 ms 17588 KB Output is correct
92 Correct 327 ms 45984 KB Output is correct
93 Correct 306 ms 45840 KB Output is correct
94 Correct 462 ms 45616 KB Output is correct
95 Correct 454 ms 45876 KB Output is correct
96 Correct 0 ms 212 KB Output is correct
97 Correct 29 ms 4680 KB Output is correct
98 Correct 45 ms 9272 KB Output is correct
99 Correct 381 ms 67564 KB Output is correct
100 Correct 8 ms 1680 KB Output is correct
101 Correct 31 ms 5944 KB Output is correct
102 Correct 60 ms 10592 KB Output is correct
103 Correct 167 ms 19120 KB Output is correct
104 Correct 209 ms 25964 KB Output is correct
105 Correct 279 ms 33084 KB Output is correct
106 Correct 321 ms 40240 KB Output is correct
107 Correct 392 ms 47244 KB Output is correct
108 Correct 1 ms 212 KB Output is correct
109 Correct 1 ms 296 KB Output is correct
110 Correct 1 ms 212 KB Output is correct
111 Correct 0 ms 300 KB Output is correct
112 Correct 0 ms 296 KB Output is correct
113 Correct 0 ms 304 KB Output is correct
114 Correct 0 ms 212 KB Output is correct
115 Correct 0 ms 212 KB Output is correct
116 Correct 0 ms 212 KB Output is correct
117 Correct 0 ms 212 KB Output is correct
118 Correct 1 ms 212 KB Output is correct
119 Correct 2 ms 596 KB Output is correct
120 Correct 2 ms 596 KB Output is correct
121 Correct 188 ms 30764 KB Output is correct
122 Correct 268 ms 45196 KB Output is correct
123 Correct 320 ms 44408 KB Output is correct
124 Correct 0 ms 212 KB Output is correct
125 Correct 0 ms 212 KB Output is correct
126 Correct 0 ms 212 KB Output is correct
127 Correct 389 ms 63620 KB Output is correct
128 Correct 403 ms 63904 KB Output is correct
129 Correct 380 ms 66476 KB Output is correct
130 Correct 3 ms 980 KB Output is correct
131 Correct 4 ms 1236 KB Output is correct
132 Correct 187 ms 27084 KB Output is correct
133 Correct 285 ms 43744 KB Output is correct
134 Correct 453 ms 54400 KB Output is correct
135 Correct 420 ms 71136 KB Output is correct
136 Correct 400 ms 69036 KB Output is correct
137 Correct 431 ms 71780 KB Output is correct
138 Correct 506 ms 61072 KB Output is correct
139 Correct 382 ms 52436 KB Output is correct
140 Correct 0 ms 212 KB Output is correct
141 Correct 53 ms 8780 KB Output is correct
142 Correct 19 ms 4052 KB Output is correct
143 Correct 45 ms 8760 KB Output is correct
144 Correct 70 ms 13352 KB Output is correct
145 Correct 223 ms 31464 KB Output is correct
146 Correct 272 ms 39824 KB Output is correct
147 Correct 342 ms 47964 KB Output is correct
148 Correct 413 ms 55228 KB Output is correct
149 Correct 490 ms 63536 KB Output is correct
150 Correct 417 ms 65776 KB Output is correct
151 Correct 394 ms 70868 KB Output is correct
152 Correct 5 ms 1108 KB Output is correct
153 Correct 6 ms 1620 KB Output is correct
154 Correct 175 ms 28008 KB Output is correct
155 Correct 287 ms 42656 KB Output is correct
156 Correct 417 ms 56940 KB Output is correct
157 Correct 1 ms 296 KB Output is correct
158 Correct 0 ms 212 KB Output is correct
159 Correct 0 ms 300 KB Output is correct
160 Correct 1 ms 300 KB Output is correct
161 Correct 480 ms 71172 KB Output is correct
162 Correct 403 ms 63788 KB Output is correct
163 Correct 393 ms 57312 KB Output is correct
164 Correct 401 ms 56508 KB Output is correct
165 Incorrect 392 ms 62188 KB Solution announced impossible, but it is possible.
166 Halted 0 ms 0 KB -