Submission #1053122

# Submission time Handle Problem Language Result Execution time Memory
1053122 2024-08-11T08:55:25 Z vnm06 Fountain Parks (IOI21_parks) C++17
15 / 100
95 ms 39832 KB
#include "parks.h"
#include<bits/stdc++.h>
using namespace std;

bool pos[200004];
int used[3][200004];
vector<int> gr[200004];


void dfs(int v)
{
    pos[v]=1;
    int brs=gr[v].size();
    for(int i=0; i<brs; i++)
    {
        int nv=gr[v][i];
        if(!pos[nv]) dfs(nv);
    }
}

int construct_roads(std::vector<int> x, std::vector<int> y) {
    if (x.size() == 1) {
	build({}, {}, {}, {});
        return 1;
    }
    std::vector<int> u, v, a, b;
    for(int i=0; i<x.size(); i++)
    {
        used[x[i]/2-1][y[i]]=i+1;
    }
    for(int i=2; i<=200000; i+=2)
    {
        if(used[0][i] && used[0][i+2])
        {
            u.push_back(used[0][i]-1);
            v.push_back(used[0][i+2]-1);
            a.push_back(1);
            b.push_back(i+1);
        }
        if(used[1][i] && used[1][i+2])
        {
            u.push_back(used[1][i]-1);
            v.push_back(used[1][i+2]-1);
            a.push_back(5);
            b.push_back(i+1);
        }
        if(used[1][i] && used[0][i])
        {
            u.push_back(used[1][i]-1);
            v.push_back(used[0][i]-1);
            a.push_back(3);
            b.push_back(i+1);
        }
    }
    for(int i=0; i<u.size(); i++)
    {
        gr[u[i]].push_back(v[i]);
        gr[v[i]].push_back(u[i]);
    }
    dfs(0);
    for(int i=0; i<x.size(); i++) if(!pos[i]) return 0;
    build(u, v, a, b);
    return 1;
}

Compilation message

parks.cpp: In function 'int construct_roads(std::vector<int>, std::vector<int>)':
parks.cpp:27:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for(int i=0; i<x.size(); i++)
      |                  ~^~~~~~~~~
parks.cpp:55:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |     for(int i=0; i<u.size(); i++)
      |                  ~^~~~~~~~~
parks.cpp:61:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |     for(int i=0; i<x.size(); i++) if(!pos[i]) return 0;
      |                  ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6744 KB Output is correct
2 Correct 1 ms 6748 KB Output is correct
3 Correct 1 ms 6748 KB Output is correct
4 Correct 1 ms 6748 KB Output is correct
5 Correct 1 ms 6748 KB Output is correct
6 Correct 1 ms 6748 KB Output is correct
7 Correct 1 ms 6748 KB Output is correct
8 Correct 1 ms 6748 KB Output is correct
9 Correct 35 ms 20392 KB Output is correct
10 Correct 4 ms 8284 KB Output is correct
11 Correct 17 ms 14232 KB Output is correct
12 Correct 5 ms 9052 KB Output is correct
13 Correct 10 ms 10964 KB Output is correct
14 Correct 1 ms 6748 KB Output is correct
15 Correct 1 ms 6748 KB Output is correct
16 Correct 34 ms 18692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6744 KB Output is correct
2 Correct 1 ms 6748 KB Output is correct
3 Correct 1 ms 6748 KB Output is correct
4 Correct 1 ms 6748 KB Output is correct
5 Correct 1 ms 6748 KB Output is correct
6 Correct 1 ms 6748 KB Output is correct
7 Correct 1 ms 6748 KB Output is correct
8 Correct 1 ms 6748 KB Output is correct
9 Correct 35 ms 20392 KB Output is correct
10 Correct 4 ms 8284 KB Output is correct
11 Correct 17 ms 14232 KB Output is correct
12 Correct 5 ms 9052 KB Output is correct
13 Correct 10 ms 10964 KB Output is correct
14 Correct 1 ms 6748 KB Output is correct
15 Correct 1 ms 6748 KB Output is correct
16 Correct 34 ms 18692 KB Output is correct
17 Correct 1 ms 6744 KB Output is correct
18 Correct 1 ms 6748 KB Output is correct
19 Correct 1 ms 6748 KB Output is correct
20 Correct 1 ms 6748 KB Output is correct
21 Correct 1 ms 6748 KB Output is correct
22 Correct 1 ms 6748 KB Output is correct
23 Correct 95 ms 39640 KB Output is correct
24 Correct 1 ms 6748 KB Output is correct
25 Correct 2 ms 6748 KB Output is correct
26 Correct 2 ms 7068 KB Output is correct
27 Correct 2 ms 7004 KB Output is correct
28 Correct 38 ms 19900 KB Output is correct
29 Correct 57 ms 26536 KB Output is correct
30 Correct 80 ms 33204 KB Output is correct
31 Correct 92 ms 39832 KB Output is correct
32 Correct 1 ms 6744 KB Output is correct
33 Correct 1 ms 6748 KB Output is correct
34 Correct 1 ms 6572 KB Output is correct
35 Correct 1 ms 6748 KB Output is correct
36 Correct 1 ms 6748 KB Output is correct
37 Correct 1 ms 6748 KB Output is correct
38 Correct 1 ms 6744 KB Output is correct
39 Correct 1 ms 6748 KB Output is correct
40 Correct 1 ms 6744 KB Output is correct
41 Correct 1 ms 6748 KB Output is correct
42 Correct 1 ms 6748 KB Output is correct
43 Correct 1 ms 6748 KB Output is correct
44 Correct 2 ms 6748 KB Output is correct
45 Correct 35 ms 18992 KB Output is correct
46 Correct 50 ms 25000 KB Output is correct
47 Correct 53 ms 24744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6744 KB Output is correct
2 Correct 1 ms 6748 KB Output is correct
3 Correct 1 ms 6748 KB Output is correct
4 Correct 1 ms 6748 KB Output is correct
5 Correct 1 ms 6748 KB Output is correct
6 Correct 1 ms 6748 KB Output is correct
7 Correct 1 ms 6748 KB Output is correct
8 Correct 1 ms 6748 KB Output is correct
9 Correct 35 ms 20392 KB Output is correct
10 Correct 4 ms 8284 KB Output is correct
11 Correct 17 ms 14232 KB Output is correct
12 Correct 5 ms 9052 KB Output is correct
13 Correct 10 ms 10964 KB Output is correct
14 Correct 1 ms 6748 KB Output is correct
15 Correct 1 ms 6748 KB Output is correct
16 Correct 34 ms 18692 KB Output is correct
17 Correct 1 ms 6744 KB Output is correct
18 Correct 1 ms 6748 KB Output is correct
19 Correct 1 ms 6748 KB Output is correct
20 Correct 1 ms 6748 KB Output is correct
21 Correct 1 ms 6748 KB Output is correct
22 Correct 1 ms 6748 KB Output is correct
23 Correct 95 ms 39640 KB Output is correct
24 Correct 1 ms 6748 KB Output is correct
25 Correct 2 ms 6748 KB Output is correct
26 Correct 2 ms 7068 KB Output is correct
27 Correct 2 ms 7004 KB Output is correct
28 Correct 38 ms 19900 KB Output is correct
29 Correct 57 ms 26536 KB Output is correct
30 Correct 80 ms 33204 KB Output is correct
31 Correct 92 ms 39832 KB Output is correct
32 Correct 1 ms 6744 KB Output is correct
33 Correct 1 ms 6748 KB Output is correct
34 Correct 1 ms 6572 KB Output is correct
35 Correct 1 ms 6748 KB Output is correct
36 Correct 1 ms 6748 KB Output is correct
37 Correct 1 ms 6748 KB Output is correct
38 Correct 1 ms 6744 KB Output is correct
39 Correct 1 ms 6748 KB Output is correct
40 Correct 1 ms 6744 KB Output is correct
41 Correct 1 ms 6748 KB Output is correct
42 Correct 1 ms 6748 KB Output is correct
43 Correct 1 ms 6748 KB Output is correct
44 Correct 2 ms 6748 KB Output is correct
45 Correct 35 ms 18992 KB Output is correct
46 Correct 50 ms 25000 KB Output is correct
47 Correct 53 ms 24744 KB Output is correct
48 Incorrect 1 ms 6744 KB Solution announced impossible, but it is possible.
49 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6744 KB Output is correct
2 Correct 1 ms 6748 KB Output is correct
3 Correct 1 ms 6748 KB Output is correct
4 Correct 1 ms 6748 KB Output is correct
5 Correct 1 ms 6748 KB Output is correct
6 Correct 1 ms 6748 KB Output is correct
7 Correct 1 ms 6748 KB Output is correct
8 Correct 1 ms 6748 KB Output is correct
9 Correct 35 ms 20392 KB Output is correct
10 Correct 4 ms 8284 KB Output is correct
11 Correct 17 ms 14232 KB Output is correct
12 Correct 5 ms 9052 KB Output is correct
13 Correct 10 ms 10964 KB Output is correct
14 Correct 1 ms 6748 KB Output is correct
15 Correct 1 ms 6748 KB Output is correct
16 Correct 34 ms 18692 KB Output is correct
17 Runtime error 5 ms 13148 KB Execution killed with signal 11
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6744 KB Output is correct
2 Correct 1 ms 6748 KB Output is correct
3 Correct 1 ms 6748 KB Output is correct
4 Correct 1 ms 6748 KB Output is correct
5 Correct 1 ms 6748 KB Output is correct
6 Correct 1 ms 6748 KB Output is correct
7 Correct 1 ms 6748 KB Output is correct
8 Correct 1 ms 6748 KB Output is correct
9 Correct 35 ms 20392 KB Output is correct
10 Correct 4 ms 8284 KB Output is correct
11 Correct 17 ms 14232 KB Output is correct
12 Correct 5 ms 9052 KB Output is correct
13 Correct 10 ms 10964 KB Output is correct
14 Correct 1 ms 6748 KB Output is correct
15 Correct 1 ms 6748 KB Output is correct
16 Correct 34 ms 18692 KB Output is correct
17 Runtime error 25 ms 19536 KB Execution killed with signal 11
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6744 KB Output is correct
2 Correct 1 ms 6748 KB Output is correct
3 Correct 1 ms 6748 KB Output is correct
4 Correct 1 ms 6748 KB Output is correct
5 Correct 1 ms 6748 KB Output is correct
6 Correct 1 ms 6748 KB Output is correct
7 Correct 1 ms 6748 KB Output is correct
8 Correct 1 ms 6748 KB Output is correct
9 Correct 35 ms 20392 KB Output is correct
10 Correct 4 ms 8284 KB Output is correct
11 Correct 17 ms 14232 KB Output is correct
12 Correct 5 ms 9052 KB Output is correct
13 Correct 10 ms 10964 KB Output is correct
14 Correct 1 ms 6748 KB Output is correct
15 Correct 1 ms 6748 KB Output is correct
16 Correct 34 ms 18692 KB Output is correct
17 Correct 1 ms 6744 KB Output is correct
18 Correct 1 ms 6748 KB Output is correct
19 Correct 1 ms 6748 KB Output is correct
20 Correct 1 ms 6748 KB Output is correct
21 Correct 1 ms 6748 KB Output is correct
22 Correct 1 ms 6748 KB Output is correct
23 Correct 95 ms 39640 KB Output is correct
24 Correct 1 ms 6748 KB Output is correct
25 Correct 2 ms 6748 KB Output is correct
26 Correct 2 ms 7068 KB Output is correct
27 Correct 2 ms 7004 KB Output is correct
28 Correct 38 ms 19900 KB Output is correct
29 Correct 57 ms 26536 KB Output is correct
30 Correct 80 ms 33204 KB Output is correct
31 Correct 92 ms 39832 KB Output is correct
32 Correct 1 ms 6744 KB Output is correct
33 Correct 1 ms 6748 KB Output is correct
34 Correct 1 ms 6572 KB Output is correct
35 Correct 1 ms 6748 KB Output is correct
36 Correct 1 ms 6748 KB Output is correct
37 Correct 1 ms 6748 KB Output is correct
38 Correct 1 ms 6744 KB Output is correct
39 Correct 1 ms 6748 KB Output is correct
40 Correct 1 ms 6744 KB Output is correct
41 Correct 1 ms 6748 KB Output is correct
42 Correct 1 ms 6748 KB Output is correct
43 Correct 1 ms 6748 KB Output is correct
44 Correct 2 ms 6748 KB Output is correct
45 Correct 35 ms 18992 KB Output is correct
46 Correct 50 ms 25000 KB Output is correct
47 Correct 53 ms 24744 KB Output is correct
48 Incorrect 1 ms 6744 KB Solution announced impossible, but it is possible.
49 Halted 0 ms 0 KB -