Submission #824726

# Submission time Handle Problem Language Result Execution time Memory
824726 2023-08-14T09:12:32 Z andrei_boaca Fountain Parks (IOI21_parks) C++17
15 / 100
365 ms 53800 KB
#include "parks.h"
#include <bits/stdc++.h>
//#include "grader.cpp"
using namespace std;

typedef pair<int,int> pii;
map<pii,int> ind;
struct point
{
    int x,y;
} v[200005];
int k;
vector<int> myy[200005];
vector<int> muchii[200005];
bool have[11][200005];
bool use[200005];
void dfs(int nod)
{
    use[nod]=1;
    for(int i:muchii[nod])
        if(!use[i])
            dfs(i);
}
int construct_roads(std::vector<int> X, std::vector<int> Y)
{
    k=X.size();
    int xmax=0;
    for(int i=0;i<k;i++)
    {
        v[i]={X[i],Y[i]};
        ind[{X[i],Y[i]}]=i;
        xmax=max(xmax,X[i]);
        myy[X[i]].push_back(Y[i]);
        have[X[i]][Y[i]]=1;
    }
    if(xmax<=2)
    {
        sort(myy[2].begin(),myy[2].end());
        vector<int> U,V,a,b;
        for(int i=1;i<myy[2].size();i++)
        {
            if(myy[2][i]-myy[2][i-1]!=2)
                return 0;
            int x=2;
            int yu=myy[2][i-1];
            int yv=myy[2][i];
            U.push_back(ind[{x,yu}]);
            V.push_back(ind[{x,yv}]);
            a.push_back(x-1);
            b.push_back(yv-1);
        }
        build(U,V,a,b);
        return 1;
    }
    if(xmax<=4)
    {
        sort(myy[2].begin(),myy[2].end());
        sort(myy[4].begin(),myy[4].end());
        vector<int> U,V,A,B;
        for(int i=2;i<=200000;i+=2)
            if(have[2][i]&&have[2][i-2])
            {
                int a=ind[{2,i}];
                int b=ind[{2,i-2}];
                U.push_back(a);
                V.push_back(b);
                muchii[a].push_back(b);
                muchii[b].push_back(a);
                A.push_back(1);
                B.push_back(i-1);
            }
        for(int i=2;i<=200000;i+=2)
            if(have[4][i]&&have[4][i-2])
            {
                int a=ind[{4,i}];
                int b=ind[{4,i-2}];
                U.push_back(a);
                V.push_back(b);
                muchii[a].push_back(b);
                muchii[b].push_back(a);
                A.push_back(5);
                B.push_back(i-1);
            }
        for(int i=2;i<=200000;i+=2)
            if(have[2][i]&&have[4][i])
            {
                int a=ind[{2,i}];
                int b=ind[{4,i}];
                U.push_back(a);
                V.push_back(b);
                muchii[a].push_back(b);
                muchii[b].push_back(a);
                A.push_back(3);
                B.push_back(i+1);
            }
        dfs(0);
        for(int i=0;i<k;i++)
            if(!use[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:40:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |         for(int i=1;i<myy[2].size();i++)
      |                     ~^~~~~~~~~~~~~~
parks.cpp:103:1: warning: control reaches end of non-void function [-Wreturn-type]
  103 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 4 ms 9684 KB Output is correct
2 Correct 4 ms 9684 KB Output is correct
3 Correct 4 ms 9684 KB Output is correct
4 Correct 4 ms 9684 KB Output is correct
5 Correct 5 ms 9624 KB Output is correct
6 Correct 5 ms 9684 KB Output is correct
7 Correct 4 ms 9684 KB Output is correct
8 Correct 4 ms 9684 KB Output is correct
9 Correct 94 ms 23956 KB Output is correct
10 Correct 11 ms 11348 KB Output is correct
11 Correct 43 ms 17440 KB Output is correct
12 Correct 14 ms 11988 KB Output is correct
13 Correct 28 ms 14480 KB Output is correct
14 Correct 5 ms 9812 KB Output is correct
15 Correct 5 ms 9872 KB Output is correct
16 Correct 94 ms 23904 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 9684 KB Output is correct
2 Correct 4 ms 9684 KB Output is correct
3 Correct 4 ms 9684 KB Output is correct
4 Correct 4 ms 9684 KB Output is correct
5 Correct 5 ms 9624 KB Output is correct
6 Correct 5 ms 9684 KB Output is correct
7 Correct 4 ms 9684 KB Output is correct
8 Correct 4 ms 9684 KB Output is correct
9 Correct 94 ms 23956 KB Output is correct
10 Correct 11 ms 11348 KB Output is correct
11 Correct 43 ms 17440 KB Output is correct
12 Correct 14 ms 11988 KB Output is correct
13 Correct 28 ms 14480 KB Output is correct
14 Correct 5 ms 9812 KB Output is correct
15 Correct 5 ms 9872 KB Output is correct
16 Correct 94 ms 23904 KB Output is correct
17 Correct 5 ms 9684 KB Output is correct
18 Correct 5 ms 9684 KB Output is correct
19 Correct 5 ms 9684 KB Output is correct
20 Correct 6 ms 9812 KB Output is correct
21 Correct 5 ms 9684 KB Output is correct
22 Correct 6 ms 9684 KB Output is correct
23 Correct 312 ms 53800 KB Output is correct
24 Correct 6 ms 9684 KB Output is correct
25 Correct 6 ms 9940 KB Output is correct
26 Correct 7 ms 10196 KB Output is correct
27 Correct 7 ms 10324 KB Output is correct
28 Correct 110 ms 27296 KB Output is correct
29 Correct 169 ms 36216 KB Output is correct
30 Correct 242 ms 44968 KB Output is correct
31 Correct 365 ms 53796 KB Output is correct
32 Correct 5 ms 9684 KB Output is correct
33 Correct 4 ms 9684 KB Output is correct
34 Correct 4 ms 9708 KB Output is correct
35 Correct 7 ms 9684 KB Output is correct
36 Correct 5 ms 9672 KB Output is correct
37 Correct 5 ms 9716 KB Output is correct
38 Correct 7 ms 9708 KB Output is correct
39 Correct 5 ms 9684 KB Output is correct
40 Correct 7 ms 9708 KB Output is correct
41 Correct 6 ms 9684 KB Output is correct
42 Correct 5 ms 9684 KB Output is correct
43 Correct 6 ms 9976 KB Output is correct
44 Correct 6 ms 10196 KB Output is correct
45 Correct 115 ms 28768 KB Output is correct
46 Correct 181 ms 37764 KB Output is correct
47 Correct 199 ms 37648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 9684 KB Output is correct
2 Correct 4 ms 9684 KB Output is correct
3 Correct 4 ms 9684 KB Output is correct
4 Correct 4 ms 9684 KB Output is correct
5 Correct 5 ms 9624 KB Output is correct
6 Correct 5 ms 9684 KB Output is correct
7 Correct 4 ms 9684 KB Output is correct
8 Correct 4 ms 9684 KB Output is correct
9 Correct 94 ms 23956 KB Output is correct
10 Correct 11 ms 11348 KB Output is correct
11 Correct 43 ms 17440 KB Output is correct
12 Correct 14 ms 11988 KB Output is correct
13 Correct 28 ms 14480 KB Output is correct
14 Correct 5 ms 9812 KB Output is correct
15 Correct 5 ms 9872 KB Output is correct
16 Correct 94 ms 23904 KB Output is correct
17 Correct 5 ms 9684 KB Output is correct
18 Correct 5 ms 9684 KB Output is correct
19 Correct 5 ms 9684 KB Output is correct
20 Correct 6 ms 9812 KB Output is correct
21 Correct 5 ms 9684 KB Output is correct
22 Correct 6 ms 9684 KB Output is correct
23 Correct 312 ms 53800 KB Output is correct
24 Correct 6 ms 9684 KB Output is correct
25 Correct 6 ms 9940 KB Output is correct
26 Correct 7 ms 10196 KB Output is correct
27 Correct 7 ms 10324 KB Output is correct
28 Correct 110 ms 27296 KB Output is correct
29 Correct 169 ms 36216 KB Output is correct
30 Correct 242 ms 44968 KB Output is correct
31 Correct 365 ms 53796 KB Output is correct
32 Correct 5 ms 9684 KB Output is correct
33 Correct 4 ms 9684 KB Output is correct
34 Correct 4 ms 9708 KB Output is correct
35 Correct 7 ms 9684 KB Output is correct
36 Correct 5 ms 9672 KB Output is correct
37 Correct 5 ms 9716 KB Output is correct
38 Correct 7 ms 9708 KB Output is correct
39 Correct 5 ms 9684 KB Output is correct
40 Correct 7 ms 9708 KB Output is correct
41 Correct 6 ms 9684 KB Output is correct
42 Correct 5 ms 9684 KB Output is correct
43 Correct 6 ms 9976 KB Output is correct
44 Correct 6 ms 10196 KB Output is correct
45 Correct 115 ms 28768 KB Output is correct
46 Correct 181 ms 37764 KB Output is correct
47 Correct 199 ms 37648 KB Output is correct
48 Incorrect 5 ms 9684 KB Solution announced impossible, but it is possible.
49 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 9684 KB Output is correct
2 Correct 4 ms 9684 KB Output is correct
3 Correct 4 ms 9684 KB Output is correct
4 Correct 4 ms 9684 KB Output is correct
5 Correct 5 ms 9624 KB Output is correct
6 Correct 5 ms 9684 KB Output is correct
7 Correct 4 ms 9684 KB Output is correct
8 Correct 4 ms 9684 KB Output is correct
9 Correct 94 ms 23956 KB Output is correct
10 Correct 11 ms 11348 KB Output is correct
11 Correct 43 ms 17440 KB Output is correct
12 Correct 14 ms 11988 KB Output is correct
13 Correct 28 ms 14480 KB Output is correct
14 Correct 5 ms 9812 KB Output is correct
15 Correct 5 ms 9872 KB Output is correct
16 Correct 94 ms 23904 KB Output is correct
17 Runtime error 12 ms 19412 KB Execution killed with signal 11
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 9684 KB Output is correct
2 Correct 4 ms 9684 KB Output is correct
3 Correct 4 ms 9684 KB Output is correct
4 Correct 4 ms 9684 KB Output is correct
5 Correct 5 ms 9624 KB Output is correct
6 Correct 5 ms 9684 KB Output is correct
7 Correct 4 ms 9684 KB Output is correct
8 Correct 4 ms 9684 KB Output is correct
9 Correct 94 ms 23956 KB Output is correct
10 Correct 11 ms 11348 KB Output is correct
11 Correct 43 ms 17440 KB Output is correct
12 Correct 14 ms 11988 KB Output is correct
13 Correct 28 ms 14480 KB Output is correct
14 Correct 5 ms 9812 KB Output is correct
15 Correct 5 ms 9872 KB Output is correct
16 Correct 94 ms 23904 KB Output is correct
17 Runtime error 43 ms 25752 KB Execution killed with signal 11
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 9684 KB Output is correct
2 Correct 4 ms 9684 KB Output is correct
3 Correct 4 ms 9684 KB Output is correct
4 Correct 4 ms 9684 KB Output is correct
5 Correct 5 ms 9624 KB Output is correct
6 Correct 5 ms 9684 KB Output is correct
7 Correct 4 ms 9684 KB Output is correct
8 Correct 4 ms 9684 KB Output is correct
9 Correct 94 ms 23956 KB Output is correct
10 Correct 11 ms 11348 KB Output is correct
11 Correct 43 ms 17440 KB Output is correct
12 Correct 14 ms 11988 KB Output is correct
13 Correct 28 ms 14480 KB Output is correct
14 Correct 5 ms 9812 KB Output is correct
15 Correct 5 ms 9872 KB Output is correct
16 Correct 94 ms 23904 KB Output is correct
17 Correct 5 ms 9684 KB Output is correct
18 Correct 5 ms 9684 KB Output is correct
19 Correct 5 ms 9684 KB Output is correct
20 Correct 6 ms 9812 KB Output is correct
21 Correct 5 ms 9684 KB Output is correct
22 Correct 6 ms 9684 KB Output is correct
23 Correct 312 ms 53800 KB Output is correct
24 Correct 6 ms 9684 KB Output is correct
25 Correct 6 ms 9940 KB Output is correct
26 Correct 7 ms 10196 KB Output is correct
27 Correct 7 ms 10324 KB Output is correct
28 Correct 110 ms 27296 KB Output is correct
29 Correct 169 ms 36216 KB Output is correct
30 Correct 242 ms 44968 KB Output is correct
31 Correct 365 ms 53796 KB Output is correct
32 Correct 5 ms 9684 KB Output is correct
33 Correct 4 ms 9684 KB Output is correct
34 Correct 4 ms 9708 KB Output is correct
35 Correct 7 ms 9684 KB Output is correct
36 Correct 5 ms 9672 KB Output is correct
37 Correct 5 ms 9716 KB Output is correct
38 Correct 7 ms 9708 KB Output is correct
39 Correct 5 ms 9684 KB Output is correct
40 Correct 7 ms 9708 KB Output is correct
41 Correct 6 ms 9684 KB Output is correct
42 Correct 5 ms 9684 KB Output is correct
43 Correct 6 ms 9976 KB Output is correct
44 Correct 6 ms 10196 KB Output is correct
45 Correct 115 ms 28768 KB Output is correct
46 Correct 181 ms 37764 KB Output is correct
47 Correct 199 ms 37648 KB Output is correct
48 Incorrect 5 ms 9684 KB Solution announced impossible, but it is possible.
49 Halted 0 ms 0 KB -