답안 #1011766

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1011766 2024-07-01T08:09:46 Z bachhoangxuan 분수 공원 (IOI21_parks) C++17
100 / 100
470 ms 29908 KB
#include "parks.h"
#include<bits/stdc++.h>
using namespace std;
int dx[]={0,0,2,-2},
    dy[]={2,-2,0,0};

int construct_roads(std::vector<int> X, std::vector<int> Y) {
    int N=(int)X.size();
    vector<int> U,V,A,B;

    map<pair<int,int>,int> mp;
    for(int i=0;i<N;i++) mp[{X[i],Y[i]}]=i;

    int cnt=0;
    vector<bool> vis(N);
    queue<int> q;
    q.push(0);vis[0]=1;
    while(!q.empty()){
        int u=q.front();q.pop();cnt++;
        for(int t=0;t<4;t++){
            int xt=X[u]+dx[t],yt=Y[u]+dy[t];
            if(mp.count({xt,yt})){
                int v=mp[{xt,yt}];
                if(!vis[v]) q.push(v),vis[v]=1;
            }
        }
    }
    if(cnt!=N) return 0;

    for(int i=0;i<N;i++){
        int x=X[i],y=Y[i];
        if(mp.count({x+2,y})){
            if(!((x+y)&2) || !mp.count({x,y+2}) || !mp.count({x+2,y+2})){
                U.push_back(i);V.push_back(mp[{x+2,y}]);
                A.push_back(x+1);
                if((x+y)&2) B.push_back(y+1);
                else B.push_back(y-1);
            }
        }
        if(mp.count({x,y+2})){
            if(((x+y)&2) || !mp.count({x+2,y}) || !mp.count({x+2,y+2})){
                U.push_back(i);V.push_back(mp[{x,y+2}]);
                B.push_back(y+1);
                if((x+y)&2) A.push_back(x-1);
                else A.push_back(x+1);
            }
        }
    }

    build(U,V,A,B);
    return 1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 0 ms 348 KB Output is correct
5 Correct 0 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 120 ms 13896 KB Output is correct
10 Correct 10 ms 1884 KB Output is correct
11 Correct 58 ms 7624 KB Output is correct
12 Correct 14 ms 2648 KB Output is correct
13 Correct 23 ms 4188 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 119 ms 13780 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 0 ms 348 KB Output is correct
5 Correct 0 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 120 ms 13896 KB Output is correct
10 Correct 10 ms 1884 KB Output is correct
11 Correct 58 ms 7624 KB Output is correct
12 Correct 14 ms 2648 KB Output is correct
13 Correct 23 ms 4188 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 119 ms 13780 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 367 ms 27172 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 604 KB Output is correct
26 Correct 2 ms 604 KB Output is correct
27 Correct 1 ms 604 KB Output is correct
28 Correct 104 ms 11112 KB Output is correct
29 Correct 164 ms 16612 KB Output is correct
30 Correct 224 ms 21972 KB Output is correct
31 Correct 290 ms 27436 KB Output is correct
32 Correct 0 ms 344 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 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 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 1 ms 604 KB Output is correct
45 Correct 148 ms 13792 KB Output is correct
46 Correct 211 ms 19944 KB Output is correct
47 Correct 220 ms 19852 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 0 ms 348 KB Output is correct
5 Correct 0 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 120 ms 13896 KB Output is correct
10 Correct 10 ms 1884 KB Output is correct
11 Correct 58 ms 7624 KB Output is correct
12 Correct 14 ms 2648 KB Output is correct
13 Correct 23 ms 4188 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 119 ms 13780 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 367 ms 27172 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 604 KB Output is correct
26 Correct 2 ms 604 KB Output is correct
27 Correct 1 ms 604 KB Output is correct
28 Correct 104 ms 11112 KB Output is correct
29 Correct 164 ms 16612 KB Output is correct
30 Correct 224 ms 21972 KB Output is correct
31 Correct 290 ms 27436 KB Output is correct
32 Correct 0 ms 344 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 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 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 1 ms 604 KB Output is correct
45 Correct 148 ms 13792 KB Output is correct
46 Correct 211 ms 19944 KB Output is correct
47 Correct 220 ms 19852 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 0 ms 348 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 348 KB Output is correct
53 Correct 0 ms 348 KB Output is correct
54 Correct 0 ms 348 KB Output is correct
55 Correct 337 ms 27024 KB Output is correct
56 Correct 0 ms 344 KB Output is correct
57 Correct 2 ms 604 KB Output is correct
58 Correct 6 ms 1372 KB Output is correct
59 Correct 4 ms 1116 KB Output is correct
60 Correct 150 ms 13712 KB Output is correct
61 Correct 203 ms 18484 KB Output is correct
62 Correct 240 ms 22704 KB Output is correct
63 Correct 310 ms 27312 KB Output is correct
64 Correct 0 ms 344 KB Output is correct
65 Correct 0 ms 348 KB Output is correct
66 Correct 1 ms 348 KB Output is correct
67 Correct 256 ms 27304 KB Output is correct
68 Correct 273 ms 27308 KB Output is correct
69 Correct 275 ms 27048 KB Output is correct
70 Correct 2 ms 600 KB Output is correct
71 Correct 3 ms 1112 KB Output is correct
72 Correct 141 ms 13784 KB Output is correct
73 Correct 228 ms 20656 KB Output is correct
74 Correct 291 ms 27488 KB Output is correct
75 Correct 289 ms 29088 KB Output is correct
76 Correct 242 ms 27308 KB Output is correct
77 Correct 2 ms 856 KB Output is correct
78 Correct 4 ms 1116 KB Output is correct
79 Correct 129 ms 14308 KB Output is correct
80 Correct 242 ms 21392 KB Output is correct
81 Correct 335 ms 28068 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 0 ms 348 KB Output is correct
5 Correct 0 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 120 ms 13896 KB Output is correct
10 Correct 10 ms 1884 KB Output is correct
11 Correct 58 ms 7624 KB Output is correct
12 Correct 14 ms 2648 KB Output is correct
13 Correct 23 ms 4188 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 119 ms 13780 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 379 ms 28192 KB Output is correct
21 Correct 381 ms 27800 KB Output is correct
22 Correct 384 ms 27960 KB Output is correct
23 Correct 275 ms 23812 KB Output is correct
24 Correct 108 ms 17744 KB Output is correct
25 Correct 95 ms 17492 KB Output is correct
26 Correct 93 ms 17504 KB Output is correct
27 Correct 393 ms 27052 KB Output is correct
28 Correct 392 ms 27044 KB Output is correct
29 Correct 434 ms 27264 KB Output is correct
30 Correct 403 ms 27048 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 18 ms 2576 KB Output is correct
33 Correct 43 ms 9304 KB Output is correct
34 Correct 278 ms 28076 KB Output is correct
35 Correct 6 ms 1112 KB Output is correct
36 Correct 26 ms 4936 KB Output is correct
37 Correct 52 ms 9296 KB Output is correct
38 Correct 128 ms 11508 KB Output is correct
39 Correct 192 ms 15552 KB Output is correct
40 Correct 248 ms 19712 KB Output is correct
41 Correct 324 ms 24352 KB Output is correct
42 Correct 443 ms 28408 KB Output is correct
43 Correct 1 ms 344 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 0 ms 348 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 0 ms 604 KB Output is correct
52 Correct 0 ms 348 KB Output is correct
53 Correct 0 ms 348 KB Output is correct
54 Correct 2 ms 344 KB Output is correct
55 Correct 1 ms 600 KB Output is correct
56 Correct 135 ms 13764 KB Output is correct
57 Correct 192 ms 19876 KB Output is correct
58 Correct 200 ms 19916 KB Output is correct
59 Correct 0 ms 348 KB Output is correct
60 Correct 0 ms 348 KB Output is correct
61 Correct 0 ms 348 KB Output is correct
62 Correct 270 ms 27172 KB Output is correct
63 Correct 252 ms 27296 KB Output is correct
64 Correct 245 ms 27164 KB Output is correct
65 Correct 2 ms 604 KB Output is correct
66 Correct 3 ms 1116 KB Output is correct
67 Correct 130 ms 13752 KB Output is correct
68 Correct 215 ms 20652 KB Output is correct
69 Correct 304 ms 27436 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 0 ms 348 KB Output is correct
5 Correct 0 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 120 ms 13896 KB Output is correct
10 Correct 10 ms 1884 KB Output is correct
11 Correct 58 ms 7624 KB Output is correct
12 Correct 14 ms 2648 KB Output is correct
13 Correct 23 ms 4188 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 119 ms 13780 KB Output is correct
17 Correct 285 ms 27684 KB Output is correct
18 Correct 270 ms 27848 KB Output is correct
19 Correct 314 ms 27916 KB Output is correct
20 Correct 407 ms 29620 KB Output is correct
21 Correct 357 ms 24752 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 44 ms 5020 KB Output is correct
24 Correct 12 ms 2140 KB Output is correct
25 Correct 36 ms 6740 KB Output is correct
26 Correct 55 ms 11088 KB Output is correct
27 Correct 175 ms 15212 KB Output is correct
28 Correct 242 ms 19248 KB Output is correct
29 Correct 313 ms 22608 KB Output is correct
30 Correct 355 ms 26120 KB Output is correct
31 Correct 408 ms 29908 KB Output is correct
32 Correct 328 ms 28928 KB Output is correct
33 Correct 264 ms 27308 KB Output is correct
34 Correct 2 ms 856 KB Output is correct
35 Correct 4 ms 1116 KB Output is correct
36 Correct 141 ms 14232 KB Output is correct
37 Correct 226 ms 21560 KB Output is correct
38 Correct 298 ms 28076 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 0 ms 348 KB Output is correct
5 Correct 0 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 120 ms 13896 KB Output is correct
10 Correct 10 ms 1884 KB Output is correct
11 Correct 58 ms 7624 KB Output is correct
12 Correct 14 ms 2648 KB Output is correct
13 Correct 23 ms 4188 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 119 ms 13780 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 367 ms 27172 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 604 KB Output is correct
26 Correct 2 ms 604 KB Output is correct
27 Correct 1 ms 604 KB Output is correct
28 Correct 104 ms 11112 KB Output is correct
29 Correct 164 ms 16612 KB Output is correct
30 Correct 224 ms 21972 KB Output is correct
31 Correct 290 ms 27436 KB Output is correct
32 Correct 0 ms 344 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 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 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 1 ms 604 KB Output is correct
45 Correct 148 ms 13792 KB Output is correct
46 Correct 211 ms 19944 KB Output is correct
47 Correct 220 ms 19852 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 0 ms 348 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 348 KB Output is correct
53 Correct 0 ms 348 KB Output is correct
54 Correct 0 ms 348 KB Output is correct
55 Correct 337 ms 27024 KB Output is correct
56 Correct 0 ms 344 KB Output is correct
57 Correct 2 ms 604 KB Output is correct
58 Correct 6 ms 1372 KB Output is correct
59 Correct 4 ms 1116 KB Output is correct
60 Correct 150 ms 13712 KB Output is correct
61 Correct 203 ms 18484 KB Output is correct
62 Correct 240 ms 22704 KB Output is correct
63 Correct 310 ms 27312 KB Output is correct
64 Correct 0 ms 344 KB Output is correct
65 Correct 0 ms 348 KB Output is correct
66 Correct 1 ms 348 KB Output is correct
67 Correct 256 ms 27304 KB Output is correct
68 Correct 273 ms 27308 KB Output is correct
69 Correct 275 ms 27048 KB Output is correct
70 Correct 2 ms 600 KB Output is correct
71 Correct 3 ms 1112 KB Output is correct
72 Correct 141 ms 13784 KB Output is correct
73 Correct 228 ms 20656 KB Output is correct
74 Correct 291 ms 27488 KB Output is correct
75 Correct 289 ms 29088 KB Output is correct
76 Correct 242 ms 27308 KB Output is correct
77 Correct 2 ms 856 KB Output is correct
78 Correct 4 ms 1116 KB Output is correct
79 Correct 129 ms 14308 KB Output is correct
80 Correct 242 ms 21392 KB Output is correct
81 Correct 335 ms 28068 KB Output is correct
82 Correct 1 ms 344 KB Output is correct
83 Correct 0 ms 348 KB Output is correct
84 Correct 0 ms 348 KB Output is correct
85 Correct 379 ms 28192 KB Output is correct
86 Correct 381 ms 27800 KB Output is correct
87 Correct 384 ms 27960 KB Output is correct
88 Correct 275 ms 23812 KB Output is correct
89 Correct 108 ms 17744 KB Output is correct
90 Correct 95 ms 17492 KB Output is correct
91 Correct 93 ms 17504 KB Output is correct
92 Correct 393 ms 27052 KB Output is correct
93 Correct 392 ms 27044 KB Output is correct
94 Correct 434 ms 27264 KB Output is correct
95 Correct 403 ms 27048 KB Output is correct
96 Correct 0 ms 344 KB Output is correct
97 Correct 18 ms 2576 KB Output is correct
98 Correct 43 ms 9304 KB Output is correct
99 Correct 278 ms 28076 KB Output is correct
100 Correct 6 ms 1112 KB Output is correct
101 Correct 26 ms 4936 KB Output is correct
102 Correct 52 ms 9296 KB Output is correct
103 Correct 128 ms 11508 KB Output is correct
104 Correct 192 ms 15552 KB Output is correct
105 Correct 248 ms 19712 KB Output is correct
106 Correct 324 ms 24352 KB Output is correct
107 Correct 443 ms 28408 KB Output is correct
108 Correct 1 ms 344 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 0 ms 348 KB Output is correct
113 Correct 0 ms 348 KB Output is correct
114 Correct 0 ms 348 KB Output is correct
115 Correct 0 ms 348 KB Output is correct
116 Correct 0 ms 604 KB Output is correct
117 Correct 0 ms 348 KB Output is correct
118 Correct 0 ms 348 KB Output is correct
119 Correct 2 ms 344 KB Output is correct
120 Correct 1 ms 600 KB Output is correct
121 Correct 135 ms 13764 KB Output is correct
122 Correct 192 ms 19876 KB Output is correct
123 Correct 200 ms 19916 KB Output is correct
124 Correct 0 ms 348 KB Output is correct
125 Correct 0 ms 348 KB Output is correct
126 Correct 0 ms 348 KB Output is correct
127 Correct 270 ms 27172 KB Output is correct
128 Correct 252 ms 27296 KB Output is correct
129 Correct 245 ms 27164 KB Output is correct
130 Correct 2 ms 604 KB Output is correct
131 Correct 3 ms 1116 KB Output is correct
132 Correct 130 ms 13752 KB Output is correct
133 Correct 215 ms 20652 KB Output is correct
134 Correct 304 ms 27436 KB Output is correct
135 Correct 285 ms 27684 KB Output is correct
136 Correct 270 ms 27848 KB Output is correct
137 Correct 314 ms 27916 KB Output is correct
138 Correct 407 ms 29620 KB Output is correct
139 Correct 357 ms 24752 KB Output is correct
140 Correct 0 ms 348 KB Output is correct
141 Correct 44 ms 5020 KB Output is correct
142 Correct 12 ms 2140 KB Output is correct
143 Correct 36 ms 6740 KB Output is correct
144 Correct 55 ms 11088 KB Output is correct
145 Correct 175 ms 15212 KB Output is correct
146 Correct 242 ms 19248 KB Output is correct
147 Correct 313 ms 22608 KB Output is correct
148 Correct 355 ms 26120 KB Output is correct
149 Correct 408 ms 29908 KB Output is correct
150 Correct 328 ms 28928 KB Output is correct
151 Correct 264 ms 27308 KB Output is correct
152 Correct 2 ms 856 KB Output is correct
153 Correct 4 ms 1116 KB Output is correct
154 Correct 141 ms 14232 KB Output is correct
155 Correct 226 ms 21560 KB Output is correct
156 Correct 298 ms 28076 KB Output is correct
157 Correct 0 ms 344 KB Output is correct
158 Correct 0 ms 348 KB Output is correct
159 Correct 0 ms 348 KB Output is correct
160 Correct 0 ms 436 KB Output is correct
161 Correct 431 ms 27560 KB Output is correct
162 Correct 275 ms 28096 KB Output is correct
163 Correct 279 ms 28024 KB Output is correct
164 Correct 289 ms 27988 KB Output is correct
165 Correct 354 ms 28016 KB Output is correct
166 Correct 391 ms 27592 KB Output is correct
167 Correct 82 ms 6864 KB Output is correct
168 Correct 23 ms 3164 KB Output is correct
169 Correct 39 ms 7600 KB Output is correct
170 Correct 77 ms 13904 KB Output is correct
171 Correct 102 ms 18516 KB Output is correct
172 Correct 206 ms 14564 KB Output is correct
173 Correct 254 ms 17088 KB Output is correct
174 Correct 308 ms 19884 KB Output is correct
175 Correct 373 ms 22484 KB Output is correct
176 Correct 391 ms 25308 KB Output is correct
177 Correct 470 ms 27992 KB Output is correct