Submission #802343

# Submission time Handle Problem Language Result Execution time Memory
802343 2023-08-02T11:45:19 Z SamAnd Fountain Parks (IOI21_parks) C++17
15 / 100
511 ms 85820 KB
#include "parks.h"
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define m_p make_pair
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
const int N = 200005;

int n;
vector<int> g[N];

bool c[N];
void dfs(int x)
{
    c[x] = true;
    for (int i = 0; i < g[x].size(); ++i)
    {
        int h = g[x][i];
        if (c[h])
            continue;
        dfs(h);
    }
}

int construct_roads(std::vector<int> x, std::vector<int> y) {
    std::vector<int> u, v, a, b;

    n = sz(x);
    vector<pair<int, int> > p;
    map<pair<int, int>, int> mp;
    for (int i = 0; i < n; ++i)
    {
        p.push_back(m_p(x[i], y[i]));
        mp[m_p(x[i], y[i])] = i;
    }
    sort(all(p));
    set<pair<int, int> > s;
    for (int i = 0; i < n; ++i)
    {
        int x = p[i].fi;
        int y = p[i].se;
        if (mp.find(m_p(x + 2, y)) != mp.end())
        {
            u.push_back(mp[m_p(x, y)]);
            v.push_back(mp[m_p(x + 2, y)]);
            if (s.find(m_p(x + 1, y - 1)) == s.end())
            {
                a.push_back(x + 1);
                b.push_back(y - 1);
            }
            else if (s.find(m_p(x + 1, y + 1)) == s.end())
            {
                a.push_back(x + 1);
                b.push_back(y + 1);
            }
            else
            {
                assert(false);
            }
            s.insert(m_p(a.back(), b.back()));
            g[u.back()].push_back(v.back());
            g[v.back()].push_back(u.back());
        }
        if (mp.find(m_p(x, y + 2)) != mp.end())
        {
            u.push_back(mp[m_p(x, y)]);
            v.push_back(mp[m_p(x, y + 2)]);
            if (s.find(m_p(x - 1, y + 1)) == s.end())
            {
                a.push_back(x - 1);
                b.push_back(y + 1);
            }
            else if (s.find(m_p(x + 1, y + 1)) == s.end())
            {
                a.push_back(x + 1);
                b.push_back(y + 1);
            }
            else
            {
                assert(false);
            }
            s.insert(m_p(a.back(), b.back()));
            g[u.back()].push_back(v.back());
            g[v.back()].push_back(u.back());
        }
    }

    dfs(0);
    for (int i = 0; i < n; ++i)
    {
        if (!c[i])
            return 0;
    }

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

Compilation message

parks.cpp: In function 'void dfs(int)':
parks.cpp:18:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |     for (int i = 0; i < g[x].size(); ++i)
      |                     ~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 5004 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 5004 KB Output is correct
4 Correct 2 ms 5004 KB Output is correct
5 Correct 2 ms 5008 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 4948 KB Output is correct
9 Correct 164 ms 31864 KB Output is correct
10 Correct 17 ms 7756 KB Output is correct
11 Correct 70 ms 19656 KB Output is correct
12 Correct 22 ms 9116 KB Output is correct
13 Correct 47 ms 14856 KB Output is correct
14 Correct 3 ms 5204 KB Output is correct
15 Correct 4 ms 5288 KB Output is correct
16 Correct 156 ms 30036 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 5004 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 5004 KB Output is correct
4 Correct 2 ms 5004 KB Output is correct
5 Correct 2 ms 5008 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 4948 KB Output is correct
9 Correct 164 ms 31864 KB Output is correct
10 Correct 17 ms 7756 KB Output is correct
11 Correct 70 ms 19656 KB Output is correct
12 Correct 22 ms 9116 KB Output is correct
13 Correct 47 ms 14856 KB Output is correct
14 Correct 3 ms 5204 KB Output is correct
15 Correct 4 ms 5288 KB Output is correct
16 Correct 156 ms 30036 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 5008 KB Output is correct
23 Correct 469 ms 67908 KB Output is correct
24 Correct 2 ms 4948 KB Output is correct
25 Correct 4 ms 5312 KB Output is correct
26 Correct 5 ms 5716 KB Output is correct
27 Correct 6 ms 5844 KB Output is correct
28 Correct 151 ms 31188 KB Output is correct
29 Correct 247 ms 43056 KB Output is correct
30 Correct 389 ms 58000 KB Output is correct
31 Correct 511 ms 67040 KB Output is correct
32 Correct 2 ms 4948 KB Output is correct
33 Correct 2 ms 4948 KB Output is correct
34 Correct 3 ms 4948 KB Output is correct
35 Correct 3 ms 4948 KB Output is correct
36 Correct 3 ms 4948 KB Output is correct
37 Correct 2 ms 5004 KB Output is correct
38 Correct 3 ms 4948 KB Output is correct
39 Correct 2 ms 4948 KB Output is correct
40 Correct 3 ms 4948 KB Output is correct
41 Correct 3 ms 4948 KB Output is correct
42 Correct 3 ms 4948 KB Output is correct
43 Correct 4 ms 5332 KB Output is correct
44 Correct 6 ms 5588 KB Output is correct
45 Correct 153 ms 30612 KB Output is correct
46 Correct 259 ms 42848 KB Output is correct
47 Correct 244 ms 42540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 5004 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 5004 KB Output is correct
4 Correct 2 ms 5004 KB Output is correct
5 Correct 2 ms 5008 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 4948 KB Output is correct
9 Correct 164 ms 31864 KB Output is correct
10 Correct 17 ms 7756 KB Output is correct
11 Correct 70 ms 19656 KB Output is correct
12 Correct 22 ms 9116 KB Output is correct
13 Correct 47 ms 14856 KB Output is correct
14 Correct 3 ms 5204 KB Output is correct
15 Correct 4 ms 5288 KB Output is correct
16 Correct 156 ms 30036 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 5008 KB Output is correct
23 Correct 469 ms 67908 KB Output is correct
24 Correct 2 ms 4948 KB Output is correct
25 Correct 4 ms 5312 KB Output is correct
26 Correct 5 ms 5716 KB Output is correct
27 Correct 6 ms 5844 KB Output is correct
28 Correct 151 ms 31188 KB Output is correct
29 Correct 247 ms 43056 KB Output is correct
30 Correct 389 ms 58000 KB Output is correct
31 Correct 511 ms 67040 KB Output is correct
32 Correct 2 ms 4948 KB Output is correct
33 Correct 2 ms 4948 KB Output is correct
34 Correct 3 ms 4948 KB Output is correct
35 Correct 3 ms 4948 KB Output is correct
36 Correct 3 ms 4948 KB Output is correct
37 Correct 2 ms 5004 KB Output is correct
38 Correct 3 ms 4948 KB Output is correct
39 Correct 2 ms 4948 KB Output is correct
40 Correct 3 ms 4948 KB Output is correct
41 Correct 3 ms 4948 KB Output is correct
42 Correct 3 ms 4948 KB Output is correct
43 Correct 4 ms 5332 KB Output is correct
44 Correct 6 ms 5588 KB Output is correct
45 Correct 153 ms 30612 KB Output is correct
46 Correct 259 ms 42848 KB Output is correct
47 Correct 244 ms 42540 KB Output is correct
48 Correct 3 ms 4948 KB Output is correct
49 Correct 2 ms 4948 KB Output is correct
50 Correct 2 ms 4948 KB Output is correct
51 Correct 2 ms 4948 KB Output is correct
52 Correct 3 ms 4948 KB Output is correct
53 Runtime error 6 ms 9940 KB Execution killed with signal 6
54 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 5004 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 5004 KB Output is correct
4 Correct 2 ms 5004 KB Output is correct
5 Correct 2 ms 5008 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 4948 KB Output is correct
9 Correct 164 ms 31864 KB Output is correct
10 Correct 17 ms 7756 KB Output is correct
11 Correct 70 ms 19656 KB Output is correct
12 Correct 22 ms 9116 KB Output is correct
13 Correct 47 ms 14856 KB Output is correct
14 Correct 3 ms 5204 KB Output is correct
15 Correct 4 ms 5288 KB Output is correct
16 Correct 156 ms 30036 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 352 ms 61328 KB Output is correct
21 Correct 379 ms 59204 KB Output is correct
22 Correct 382 ms 58096 KB Output is correct
23 Correct 291 ms 49568 KB Output is correct
24 Correct 162 ms 23844 KB Output is correct
25 Correct 312 ms 43000 KB Output is correct
26 Correct 334 ms 43008 KB Output is correct
27 Correct 380 ms 50484 KB Output is correct
28 Correct 345 ms 50376 KB Output is correct
29 Correct 410 ms 50472 KB Output is correct
30 Correct 409 ms 50436 KB Output is correct
31 Correct 3 ms 5000 KB Output is correct
32 Runtime error 16 ms 12708 KB Execution killed with signal 6
33 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 5004 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 5004 KB Output is correct
4 Correct 2 ms 5004 KB Output is correct
5 Correct 2 ms 5008 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 4948 KB Output is correct
9 Correct 164 ms 31864 KB Output is correct
10 Correct 17 ms 7756 KB Output is correct
11 Correct 70 ms 19656 KB Output is correct
12 Correct 22 ms 9116 KB Output is correct
13 Correct 47 ms 14856 KB Output is correct
14 Correct 3 ms 5204 KB Output is correct
15 Correct 4 ms 5288 KB Output is correct
16 Correct 156 ms 30036 KB Output is correct
17 Correct 412 ms 60568 KB Output is correct
18 Correct 382 ms 60124 KB Output is correct
19 Runtime error 349 ms 85820 KB Execution killed with signal 6
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 5004 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 5004 KB Output is correct
4 Correct 2 ms 5004 KB Output is correct
5 Correct 2 ms 5008 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 4948 KB Output is correct
9 Correct 164 ms 31864 KB Output is correct
10 Correct 17 ms 7756 KB Output is correct
11 Correct 70 ms 19656 KB Output is correct
12 Correct 22 ms 9116 KB Output is correct
13 Correct 47 ms 14856 KB Output is correct
14 Correct 3 ms 5204 KB Output is correct
15 Correct 4 ms 5288 KB Output is correct
16 Correct 156 ms 30036 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 5008 KB Output is correct
23 Correct 469 ms 67908 KB Output is correct
24 Correct 2 ms 4948 KB Output is correct
25 Correct 4 ms 5312 KB Output is correct
26 Correct 5 ms 5716 KB Output is correct
27 Correct 6 ms 5844 KB Output is correct
28 Correct 151 ms 31188 KB Output is correct
29 Correct 247 ms 43056 KB Output is correct
30 Correct 389 ms 58000 KB Output is correct
31 Correct 511 ms 67040 KB Output is correct
32 Correct 2 ms 4948 KB Output is correct
33 Correct 2 ms 4948 KB Output is correct
34 Correct 3 ms 4948 KB Output is correct
35 Correct 3 ms 4948 KB Output is correct
36 Correct 3 ms 4948 KB Output is correct
37 Correct 2 ms 5004 KB Output is correct
38 Correct 3 ms 4948 KB Output is correct
39 Correct 2 ms 4948 KB Output is correct
40 Correct 3 ms 4948 KB Output is correct
41 Correct 3 ms 4948 KB Output is correct
42 Correct 3 ms 4948 KB Output is correct
43 Correct 4 ms 5332 KB Output is correct
44 Correct 6 ms 5588 KB Output is correct
45 Correct 153 ms 30612 KB Output is correct
46 Correct 259 ms 42848 KB Output is correct
47 Correct 244 ms 42540 KB Output is correct
48 Correct 3 ms 4948 KB Output is correct
49 Correct 2 ms 4948 KB Output is correct
50 Correct 2 ms 4948 KB Output is correct
51 Correct 2 ms 4948 KB Output is correct
52 Correct 3 ms 4948 KB Output is correct
53 Runtime error 6 ms 9940 KB Execution killed with signal 6
54 Halted 0 ms 0 KB -