답안 #951235

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
951235 2024-03-21T13:01:01 Z Trisanu_Das 분수 공원 (IOI21_parks) C++17
70 / 100
521 ms 71060 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 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 179 ms 33756 KB Output is correct
10 Correct 23 ms 3928 KB Output is correct
11 Correct 93 ms 19000 KB Output is correct
12 Correct 28 ms 5716 KB Output is correct
13 Correct 47 ms 10836 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 164 ms 28708 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 179 ms 33756 KB Output is correct
10 Correct 23 ms 3928 KB Output is correct
11 Correct 93 ms 19000 KB Output is correct
12 Correct 28 ms 5716 KB Output is correct
13 Correct 47 ms 10836 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 164 ms 28708 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 440 KB Output is correct
23 Correct 451 ms 67464 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 2 ms 856 KB Output is correct
26 Correct 3 ms 860 KB Output is correct
27 Correct 2 ms 856 KB Output is correct
28 Correct 165 ms 28292 KB Output is correct
29 Correct 249 ms 42420 KB Output is correct
30 Correct 338 ms 56476 KB Output is correct
31 Correct 471 ms 65140 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 0 ms 344 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 2 ms 604 KB Output is correct
44 Correct 2 ms 600 KB Output is correct
45 Correct 178 ms 30808 KB Output is correct
46 Correct 279 ms 44964 KB Output is correct
47 Correct 281 ms 44156 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 179 ms 33756 KB Output is correct
10 Correct 23 ms 3928 KB Output is correct
11 Correct 93 ms 19000 KB Output is correct
12 Correct 28 ms 5716 KB Output is correct
13 Correct 47 ms 10836 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 164 ms 28708 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 440 KB Output is correct
23 Correct 451 ms 67464 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 2 ms 856 KB Output is correct
26 Correct 3 ms 860 KB Output is correct
27 Correct 2 ms 856 KB Output is correct
28 Correct 165 ms 28292 KB Output is correct
29 Correct 249 ms 42420 KB Output is correct
30 Correct 338 ms 56476 KB Output is correct
31 Correct 471 ms 65140 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 0 ms 344 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 2 ms 604 KB Output is correct
44 Correct 2 ms 600 KB Output is correct
45 Correct 178 ms 30808 KB Output is correct
46 Correct 279 ms 44964 KB Output is correct
47 Correct 281 ms 44156 KB Output is correct
48 Correct 0 ms 344 KB Output is correct
49 Correct 1 ms 344 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 1 ms 344 KB Output is correct
52 Correct 1 ms 344 KB Output is correct
53 Correct 0 ms 348 KB Output is correct
54 Correct 0 ms 348 KB Output is correct
55 Correct 484 ms 64248 KB Output is correct
56 Correct 0 ms 344 KB Output is correct
57 Correct 3 ms 860 KB Output is correct
58 Correct 9 ms 2492 KB Output is correct
59 Correct 6 ms 1880 KB Output is correct
60 Correct 216 ms 34916 KB Output is correct
61 Correct 283 ms 45732 KB Output is correct
62 Correct 382 ms 53140 KB Output is correct
63 Correct 488 ms 67488 KB Output is correct
64 Correct 0 ms 348 KB Output is correct
65 Correct 0 ms 348 KB Output is correct
66 Correct 0 ms 344 KB Output is correct
67 Correct 395 ms 62996 KB Output is correct
68 Correct 368 ms 63320 KB Output is correct
69 Correct 383 ms 65908 KB Output is correct
70 Correct 3 ms 856 KB Output is correct
71 Correct 5 ms 1372 KB Output is correct
72 Correct 181 ms 27312 KB Output is correct
73 Correct 337 ms 43432 KB Output is correct
74 Correct 431 ms 53868 KB Output is correct
75 Correct 423 ms 65196 KB Output is correct
76 Correct 386 ms 70308 KB Output is correct
77 Correct 4 ms 1116 KB Output is correct
78 Correct 6 ms 1628 KB Output is correct
79 Correct 196 ms 28060 KB Output is correct
80 Correct 291 ms 42564 KB Output is correct
81 Correct 416 ms 56484 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 179 ms 33756 KB Output is correct
10 Correct 23 ms 3928 KB Output is correct
11 Correct 93 ms 19000 KB Output is correct
12 Correct 28 ms 5716 KB Output is correct
13 Correct 47 ms 10836 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 164 ms 28708 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 399 ms 69064 KB Output is correct
21 Correct 426 ms 64180 KB Output is correct
22 Correct 412 ms 61276 KB Output is correct
23 Correct 327 ms 51176 KB Output is correct
24 Correct 91 ms 15956 KB Output is correct
25 Correct 116 ms 16068 KB Output is correct
26 Correct 95 ms 15964 KB Output is correct
27 Correct 323 ms 44444 KB Output is correct
28 Correct 325 ms 44384 KB Output is correct
29 Correct 460 ms 44496 KB Output is correct
30 Correct 449 ms 44456 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 28 ms 4444 KB Output is correct
33 Correct 44 ms 8016 KB Output is correct
34 Correct 394 ms 65116 KB Output is correct
35 Correct 9 ms 1628 KB Output is correct
36 Correct 31 ms 5456 KB Output is correct
37 Correct 55 ms 9300 KB Output is correct
38 Correct 142 ms 18256 KB Output is correct
39 Correct 213 ms 24724 KB Output is correct
40 Correct 268 ms 31456 KB Output is correct
41 Correct 330 ms 38040 KB Output is correct
42 Correct 393 ms 44848 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 0 ms 348 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 1 ms 348 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 0 ms 344 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 0 ms 348 KB Output is correct
52 Correct 0 ms 344 KB Output is correct
53 Correct 0 ms 352 KB Output is correct
54 Correct 2 ms 604 KB Output is correct
55 Correct 2 ms 604 KB Output is correct
56 Correct 182 ms 29988 KB Output is correct
57 Correct 272 ms 44200 KB Output is correct
58 Correct 275 ms 43428 KB Output is correct
59 Correct 0 ms 344 KB Output is correct
60 Correct 0 ms 348 KB Output is correct
61 Correct 0 ms 348 KB Output is correct
62 Correct 410 ms 62044 KB Output is correct
63 Correct 436 ms 62376 KB Output is correct
64 Correct 385 ms 64936 KB Output is correct
65 Correct 3 ms 860 KB Output is correct
66 Correct 4 ms 1372 KB Output is correct
67 Correct 198 ms 26372 KB Output is correct
68 Correct 285 ms 42448 KB Output is correct
69 Correct 405 ms 52732 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 179 ms 33756 KB Output is correct
10 Correct 23 ms 3928 KB Output is correct
11 Correct 93 ms 19000 KB Output is correct
12 Correct 28 ms 5716 KB Output is correct
13 Correct 47 ms 10836 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 164 ms 28708 KB Output is correct
17 Correct 413 ms 69232 KB Output is correct
18 Correct 412 ms 66816 KB Output is correct
19 Correct 427 ms 69444 KB Output is correct
20 Correct 521 ms 59808 KB Output is correct
21 Correct 386 ms 50952 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 55 ms 8528 KB Output is correct
24 Correct 19 ms 3928 KB Output is correct
25 Correct 43 ms 8032 KB Output is correct
26 Correct 78 ms 11860 KB Output is correct
27 Correct 235 ms 30356 KB Output is correct
28 Correct 281 ms 38444 KB Output is correct
29 Correct 337 ms 46048 KB Output is correct
30 Correct 403 ms 53364 KB Output is correct
31 Correct 517 ms 61172 KB Output is correct
32 Correct 456 ms 64284 KB Output is correct
33 Correct 396 ms 69244 KB Output is correct
34 Correct 4 ms 1116 KB Output is correct
35 Correct 6 ms 1760 KB Output is correct
36 Correct 203 ms 27336 KB Output is correct
37 Correct 294 ms 41640 KB Output is correct
38 Correct 414 ms 55344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 179 ms 33756 KB Output is correct
10 Correct 23 ms 3928 KB Output is correct
11 Correct 93 ms 19000 KB Output is correct
12 Correct 28 ms 5716 KB Output is correct
13 Correct 47 ms 10836 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 164 ms 28708 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 440 KB Output is correct
23 Correct 451 ms 67464 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 2 ms 856 KB Output is correct
26 Correct 3 ms 860 KB Output is correct
27 Correct 2 ms 856 KB Output is correct
28 Correct 165 ms 28292 KB Output is correct
29 Correct 249 ms 42420 KB Output is correct
30 Correct 338 ms 56476 KB Output is correct
31 Correct 471 ms 65140 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 0 ms 344 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 2 ms 604 KB Output is correct
44 Correct 2 ms 600 KB Output is correct
45 Correct 178 ms 30808 KB Output is correct
46 Correct 279 ms 44964 KB Output is correct
47 Correct 281 ms 44156 KB Output is correct
48 Correct 0 ms 344 KB Output is correct
49 Correct 1 ms 344 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 1 ms 344 KB Output is correct
52 Correct 1 ms 344 KB Output is correct
53 Correct 0 ms 348 KB Output is correct
54 Correct 0 ms 348 KB Output is correct
55 Correct 484 ms 64248 KB Output is correct
56 Correct 0 ms 344 KB Output is correct
57 Correct 3 ms 860 KB Output is correct
58 Correct 9 ms 2492 KB Output is correct
59 Correct 6 ms 1880 KB Output is correct
60 Correct 216 ms 34916 KB Output is correct
61 Correct 283 ms 45732 KB Output is correct
62 Correct 382 ms 53140 KB Output is correct
63 Correct 488 ms 67488 KB Output is correct
64 Correct 0 ms 348 KB Output is correct
65 Correct 0 ms 348 KB Output is correct
66 Correct 0 ms 344 KB Output is correct
67 Correct 395 ms 62996 KB Output is correct
68 Correct 368 ms 63320 KB Output is correct
69 Correct 383 ms 65908 KB Output is correct
70 Correct 3 ms 856 KB Output is correct
71 Correct 5 ms 1372 KB Output is correct
72 Correct 181 ms 27312 KB Output is correct
73 Correct 337 ms 43432 KB Output is correct
74 Correct 431 ms 53868 KB Output is correct
75 Correct 423 ms 65196 KB Output is correct
76 Correct 386 ms 70308 KB Output is correct
77 Correct 4 ms 1116 KB Output is correct
78 Correct 6 ms 1628 KB Output is correct
79 Correct 196 ms 28060 KB Output is correct
80 Correct 291 ms 42564 KB Output is correct
81 Correct 416 ms 56484 KB Output is correct
82 Correct 1 ms 344 KB Output is correct
83 Correct 1 ms 348 KB Output is correct
84 Correct 0 ms 348 KB Output is correct
85 Correct 399 ms 69064 KB Output is correct
86 Correct 426 ms 64180 KB Output is correct
87 Correct 412 ms 61276 KB Output is correct
88 Correct 327 ms 51176 KB Output is correct
89 Correct 91 ms 15956 KB Output is correct
90 Correct 116 ms 16068 KB Output is correct
91 Correct 95 ms 15964 KB Output is correct
92 Correct 323 ms 44444 KB Output is correct
93 Correct 325 ms 44384 KB Output is correct
94 Correct 460 ms 44496 KB Output is correct
95 Correct 449 ms 44456 KB Output is correct
96 Correct 0 ms 348 KB Output is correct
97 Correct 28 ms 4444 KB Output is correct
98 Correct 44 ms 8016 KB Output is correct
99 Correct 394 ms 65116 KB Output is correct
100 Correct 9 ms 1628 KB Output is correct
101 Correct 31 ms 5456 KB Output is correct
102 Correct 55 ms 9300 KB Output is correct
103 Correct 142 ms 18256 KB Output is correct
104 Correct 213 ms 24724 KB Output is correct
105 Correct 268 ms 31456 KB Output is correct
106 Correct 330 ms 38040 KB Output is correct
107 Correct 393 ms 44848 KB Output is correct
108 Correct 0 ms 348 KB Output is correct
109 Correct 0 ms 348 KB Output is correct
110 Correct 0 ms 348 KB Output is correct
111 Correct 0 ms 348 KB Output is correct
112 Correct 1 ms 348 KB Output is correct
113 Correct 0 ms 348 KB Output is correct
114 Correct 0 ms 344 KB Output is correct
115 Correct 0 ms 348 KB Output is correct
116 Correct 0 ms 348 KB Output is correct
117 Correct 0 ms 344 KB Output is correct
118 Correct 0 ms 352 KB Output is correct
119 Correct 2 ms 604 KB Output is correct
120 Correct 2 ms 604 KB Output is correct
121 Correct 182 ms 29988 KB Output is correct
122 Correct 272 ms 44200 KB Output is correct
123 Correct 275 ms 43428 KB Output is correct
124 Correct 0 ms 344 KB Output is correct
125 Correct 0 ms 348 KB Output is correct
126 Correct 0 ms 348 KB Output is correct
127 Correct 410 ms 62044 KB Output is correct
128 Correct 436 ms 62376 KB Output is correct
129 Correct 385 ms 64936 KB Output is correct
130 Correct 3 ms 860 KB Output is correct
131 Correct 4 ms 1372 KB Output is correct
132 Correct 198 ms 26372 KB Output is correct
133 Correct 285 ms 42448 KB Output is correct
134 Correct 405 ms 52732 KB Output is correct
135 Correct 413 ms 69232 KB Output is correct
136 Correct 412 ms 66816 KB Output is correct
137 Correct 427 ms 69444 KB Output is correct
138 Correct 521 ms 59808 KB Output is correct
139 Correct 386 ms 50952 KB Output is correct
140 Correct 1 ms 344 KB Output is correct
141 Correct 55 ms 8528 KB Output is correct
142 Correct 19 ms 3928 KB Output is correct
143 Correct 43 ms 8032 KB Output is correct
144 Correct 78 ms 11860 KB Output is correct
145 Correct 235 ms 30356 KB Output is correct
146 Correct 281 ms 38444 KB Output is correct
147 Correct 337 ms 46048 KB Output is correct
148 Correct 403 ms 53364 KB Output is correct
149 Correct 517 ms 61172 KB Output is correct
150 Correct 456 ms 64284 KB Output is correct
151 Correct 396 ms 69244 KB Output is correct
152 Correct 4 ms 1116 KB Output is correct
153 Correct 6 ms 1760 KB Output is correct
154 Correct 203 ms 27336 KB Output is correct
155 Correct 294 ms 41640 KB Output is correct
156 Correct 414 ms 55344 KB Output is correct
157 Correct 0 ms 348 KB Output is correct
158 Correct 1 ms 344 KB Output is correct
159 Correct 1 ms 344 KB Output is correct
160 Correct 1 ms 348 KB Output is correct
161 Correct 475 ms 71060 KB Output is correct
162 Correct 416 ms 63816 KB Output is correct
163 Correct 387 ms 57524 KB Output is correct
164 Correct 378 ms 56644 KB Output is correct
165 Incorrect 464 ms 62240 KB Solution announced impossible, but it is possible.
166 Halted 0 ms 0 KB -