답안 #1050545

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1050545 2024-08-09T10:42:50 Z amine_aroua 분수 공원 (IOI21_parks) C++17
15 / 100
276 ms 46864 KB
#include "parks.h"
#include<bits/stdc++.h>
using namespace std;
vector<vector<int>> adj;
vector<bool> vis;
void dfs(int i)
{
    if(vis[i])
        return;
    vis[i] = 1;
    for(auto j : adj[i])
    {
        dfs(j);
    }
}
void add_edge(int u , int v)
{
    adj[u].push_back(v);
    adj[v].push_back(u);
}
int construct_roads(std::vector<int> x, std::vector<int> y) {
    int n= (int)x.size();
    adj.assign(n , {});
    vis.assign(n , 0);
    vector<int> u , v , a , b;
    map<pair<int, int> , int> idx;
    
    for(int i = 0 ; i <n ; i++)
    {
        idx[{x[i] , y[i]}] = i;
    }
    for(int i = 0 ; i < n ;i++)
    {
        if(idx.count({x[i] + 2 , y[i]}))
        {
            u.push_back(i);
            v.push_back(idx[{x[i] + 2 , y[i]}]);
            a.push_back(x[i] + 1);
            b.push_back(y[i] - 1);
        }
        if(idx.count({x[i] , y[i] + 2}))
        {
            u.push_back(i);
            v.push_back(idx[{x[i] , y[i] + 2}]);
            b.push_back(y[i] + 1);
            if(x[i] == 2)
            {
                a.push_back(x[i] - 1);
            }
            else
            {
                a.push_back(x[i] + 1);
            }
        }
    }
    for(int i = 0 ; i < (int)u.size() ; i++)
    {
        add_edge(u[i] , v[i]);
    }
    dfs(0);
    for(int i = 0 ; i < n ; i++)
    {
        if(!vis[i])
        {
            return 0;
        }
    }
    build(u , v , a , b);
    return 1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 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 0 ms 344 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 94 ms 21112 KB Output is correct
10 Correct 6 ms 2652 KB Output is correct
11 Correct 33 ms 11732 KB Output is correct
12 Correct 9 ms 3676 KB Output is correct
13 Correct 22 ms 7880 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 92 ms 20040 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 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 0 ms 344 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 94 ms 21112 KB Output is correct
10 Correct 6 ms 2652 KB Output is correct
11 Correct 33 ms 11732 KB Output is correct
12 Correct 9 ms 3676 KB Output is correct
13 Correct 22 ms 7880 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 92 ms 20040 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 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 276 ms 46864 KB Output is correct
24 Correct 0 ms 344 KB Output is correct
25 Correct 1 ms 604 KB Output is correct
26 Correct 2 ms 860 KB Output is correct
27 Correct 2 ms 1116 KB Output is correct
28 Correct 85 ms 19200 KB Output is correct
29 Correct 162 ms 28328 KB Output is correct
30 Correct 205 ms 38180 KB Output is correct
31 Correct 276 ms 46540 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 604 KB Output is correct
44 Correct 2 ms 856 KB Output is correct
45 Correct 94 ms 21164 KB Output is correct
46 Correct 157 ms 30892 KB Output is correct
47 Correct 172 ms 30676 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 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 0 ms 344 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 94 ms 21112 KB Output is correct
10 Correct 6 ms 2652 KB Output is correct
11 Correct 33 ms 11732 KB Output is correct
12 Correct 9 ms 3676 KB Output is correct
13 Correct 22 ms 7880 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 92 ms 20040 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 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 276 ms 46864 KB Output is correct
24 Correct 0 ms 344 KB Output is correct
25 Correct 1 ms 604 KB Output is correct
26 Correct 2 ms 860 KB Output is correct
27 Correct 2 ms 1116 KB Output is correct
28 Correct 85 ms 19200 KB Output is correct
29 Correct 162 ms 28328 KB Output is correct
30 Correct 205 ms 38180 KB Output is correct
31 Correct 276 ms 46540 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 604 KB Output is correct
44 Correct 2 ms 856 KB Output is correct
45 Correct 94 ms 21164 KB Output is correct
46 Correct 157 ms 30892 KB Output is correct
47 Correct 172 ms 30676 KB Output is correct
48 Incorrect 0 ms 344 KB Tree @(5, 3) appears more than once: for edges on positions 2 and 3
49 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 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 0 ms 344 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 94 ms 21112 KB Output is correct
10 Correct 6 ms 2652 KB Output is correct
11 Correct 33 ms 11732 KB Output is correct
12 Correct 9 ms 3676 KB Output is correct
13 Correct 22 ms 7880 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 92 ms 20040 KB Output is correct
17 Correct 0 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 239 ms 45216 KB Output is correct
21 Incorrect 233 ms 43688 KB Tree @(43593, 43597) appears more than once: for edges on positions 161 and 532
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 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 0 ms 344 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 94 ms 21112 KB Output is correct
10 Correct 6 ms 2652 KB Output is correct
11 Correct 33 ms 11732 KB Output is correct
12 Correct 9 ms 3676 KB Output is correct
13 Correct 22 ms 7880 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 92 ms 20040 KB Output is correct
17 Correct 238 ms 42664 KB Output is correct
18 Incorrect 228 ms 42328 KB Tree @(50003, 100001) appears more than once: for edges on positions 112203 and 161310
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 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 0 ms 344 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 94 ms 21112 KB Output is correct
10 Correct 6 ms 2652 KB Output is correct
11 Correct 33 ms 11732 KB Output is correct
12 Correct 9 ms 3676 KB Output is correct
13 Correct 22 ms 7880 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 92 ms 20040 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 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 276 ms 46864 KB Output is correct
24 Correct 0 ms 344 KB Output is correct
25 Correct 1 ms 604 KB Output is correct
26 Correct 2 ms 860 KB Output is correct
27 Correct 2 ms 1116 KB Output is correct
28 Correct 85 ms 19200 KB Output is correct
29 Correct 162 ms 28328 KB Output is correct
30 Correct 205 ms 38180 KB Output is correct
31 Correct 276 ms 46540 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 604 KB Output is correct
44 Correct 2 ms 856 KB Output is correct
45 Correct 94 ms 21164 KB Output is correct
46 Correct 157 ms 30892 KB Output is correct
47 Correct 172 ms 30676 KB Output is correct
48 Incorrect 0 ms 344 KB Tree @(5, 3) appears more than once: for edges on positions 2 and 3
49 Halted 0 ms 0 KB -