Submission #436800

# Submission time Handle Problem Language Result Execution time Memory
436800 2021-06-25T00:09:45 Z humbertoyusta Fountain Parks (IOI21_parks) C++17
45 / 100
641 ms 77852 KB
#include "parks.h"
#include<bits/stdc++.h>
#define f first
#define s second
#define ii pair<int,int>
using namespace std;
#define maxn 200010
#define db(x) cerr<<#x<<": "<<(x)<<"\n";

int mx[4] = { 0 , 2 , 0 , -2 };
int my[4] = { 2 , 0 , -2 , 0 };
int vis[maxn];
ii arr[maxn];
vector<int> U, V, A, B;
map<ii,int> mp;

void add_edge(int u,int v,int plus_){
    U.push_back(u);
    V.push_back(v);
    if( arr[u].f != arr[v].f ){
        A.push_back( (arr[u].f+arr[v].f)/2 );
        B.push_back( arr[u].s + plus_ );
    }
    else{
        A.push_back( arr[u].f + plus_ );
        B.push_back( (arr[u].s+arr[v].s)/2 );
    }
}

void dfs(int u,int p,int plus_){
    vis[u] = 1;
    for(int i=0; i<4; i++){
        int nx = arr[u].f + mx[i];
        int ny = arr[u].s + my[i];
        if( mp[{nx,ny}] ){
            int v = mp[{nx,ny}] - 1;
            if( vis[v] ) continue;

            int gp = p / 2 * 2 + ( p + 1 ) % 2;
            int nplus = plus_;
            if( i != gp ) nplus *= -1;

            add_edge(u,v,nplus);
            dfs(v,i,nplus);
        }
    }
}

int construct_roads(std::vector<int> x, std::vector<int> y) {
//    if (x.size() == 1) {
//        vector<int> pra;
//        build(pra, pra, pra, pra);
//        return 1;
//    }

    int n = x.size();

    for(int i=0; i<n; i++){
        arr[i] = {x[i],y[i]};
        mp[{x[i],y[i]}] = i + 1;
    }

    int u = 0;
    vis[u] = 1;
    for(int i=0; i<4; i++){
        int nx = arr[0].f + mx[i];
        int ny = arr[0].s + my[i];
        if( mp[{nx,ny}] ){
            int v = mp[{nx,ny}] - 1;
            if( vis[v] ) continue;
            int plus_ = ( i == 1 ) + ( i == 2 ) - ( i == 0 ) - ( i == 3 );
            add_edge(u,v,plus_);
            dfs(v,i,plus_);
        }
    }

    for(int i=0; i<n; i++)
        if( vis[i] == 0 )
            return 0;

    build(U, V, A, B);
    return 1;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 245 ms 37980 KB Output is correct
10 Correct 18 ms 4264 KB Output is correct
11 Correct 110 ms 21116 KB Output is correct
12 Correct 28 ms 6360 KB Output is correct
13 Correct 61 ms 12220 KB Output is correct
14 Correct 2 ms 460 KB Output is correct
15 Correct 2 ms 588 KB Output is correct
16 Correct 236 ms 32872 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 245 ms 37980 KB Output is correct
10 Correct 18 ms 4264 KB Output is correct
11 Correct 110 ms 21116 KB Output is correct
12 Correct 28 ms 6360 KB Output is correct
13 Correct 61 ms 12220 KB Output is correct
14 Correct 2 ms 460 KB Output is correct
15 Correct 2 ms 588 KB Output is correct
16 Correct 236 ms 32872 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Incorrect 1 ms 204 KB Tree @(3, 5) appears more than once: for edges on positions 0 and 2
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 245 ms 37980 KB Output is correct
10 Correct 18 ms 4264 KB Output is correct
11 Correct 110 ms 21116 KB Output is correct
12 Correct 28 ms 6360 KB Output is correct
13 Correct 61 ms 12220 KB Output is correct
14 Correct 2 ms 460 KB Output is correct
15 Correct 2 ms 588 KB Output is correct
16 Correct 236 ms 32872 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Incorrect 1 ms 204 KB Tree @(3, 5) appears more than once: for edges on positions 0 and 2
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 245 ms 37980 KB Output is correct
10 Correct 18 ms 4264 KB Output is correct
11 Correct 110 ms 21116 KB Output is correct
12 Correct 28 ms 6360 KB Output is correct
13 Correct 61 ms 12220 KB Output is correct
14 Correct 2 ms 460 KB Output is correct
15 Correct 2 ms 588 KB Output is correct
16 Correct 236 ms 32872 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 529 ms 65092 KB Output is correct
21 Correct 635 ms 60152 KB Output is correct
22 Correct 554 ms 57300 KB Output is correct
23 Correct 458 ms 58524 KB Output is correct
24 Correct 210 ms 17412 KB Output is correct
25 Correct 210 ms 18216 KB Output is correct
26 Correct 199 ms 18236 KB Output is correct
27 Correct 473 ms 40472 KB Output is correct
28 Correct 442 ms 40332 KB Output is correct
29 Correct 628 ms 40576 KB Output is correct
30 Correct 641 ms 40472 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 29 ms 4156 KB Output is correct
33 Correct 99 ms 8892 KB Output is correct
34 Correct 524 ms 61112 KB Output is correct
35 Correct 13 ms 1536 KB Output is correct
36 Correct 48 ms 5396 KB Output is correct
37 Correct 89 ms 9920 KB Output is correct
38 Correct 187 ms 14840 KB Output is correct
39 Correct 235 ms 20232 KB Output is correct
40 Correct 344 ms 25728 KB Output is correct
41 Correct 439 ms 31208 KB Output is correct
42 Correct 517 ms 36664 KB Output is correct
43 Correct 1 ms 204 KB Output is correct
44 Correct 1 ms 204 KB Output is correct
45 Correct 1 ms 204 KB Output is correct
46 Correct 1 ms 204 KB Output is correct
47 Correct 1 ms 204 KB Output is correct
48 Correct 1 ms 204 KB Output is correct
49 Correct 1 ms 204 KB Output is correct
50 Correct 1 ms 204 KB Output is correct
51 Correct 1 ms 204 KB Output is correct
52 Correct 1 ms 204 KB Output is correct
53 Correct 1 ms 204 KB Output is correct
54 Correct 2 ms 588 KB Output is correct
55 Correct 3 ms 588 KB Output is correct
56 Correct 218 ms 30376 KB Output is correct
57 Correct 345 ms 44660 KB Output is correct
58 Correct 354 ms 43928 KB Output is correct
59 Correct 1 ms 204 KB Output is correct
60 Correct 1 ms 204 KB Output is correct
61 Correct 1 ms 204 KB Output is correct
62 Correct 509 ms 64340 KB Output is correct
63 Correct 528 ms 64676 KB Output is correct
64 Correct 551 ms 67256 KB Output is correct
65 Correct 4 ms 844 KB Output is correct
66 Correct 6 ms 1228 KB Output is correct
67 Correct 233 ms 25344 KB Output is correct
68 Correct 375 ms 40980 KB Output is correct
69 Correct 536 ms 50812 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 245 ms 37980 KB Output is correct
10 Correct 18 ms 4264 KB Output is correct
11 Correct 110 ms 21116 KB Output is correct
12 Correct 28 ms 6360 KB Output is correct
13 Correct 61 ms 12220 KB Output is correct
14 Correct 2 ms 460 KB Output is correct
15 Correct 2 ms 588 KB Output is correct
16 Correct 236 ms 32872 KB Output is correct
17 Correct 590 ms 77852 KB Output is correct
18 Correct 638 ms 67964 KB Output is correct
19 Correct 563 ms 65496 KB Output is correct
20 Correct 470 ms 47792 KB Output is correct
21 Correct 457 ms 51296 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 63 ms 8172 KB Output is correct
24 Correct 21 ms 2952 KB Output is correct
25 Correct 66 ms 7896 KB Output is correct
26 Correct 117 ms 12388 KB Output is correct
27 Correct 233 ms 24568 KB Output is correct
28 Correct 309 ms 30836 KB Output is correct
29 Correct 393 ms 36944 KB Output is correct
30 Correct 493 ms 42600 KB Output is correct
31 Correct 535 ms 49164 KB Output is correct
32 Correct 560 ms 60268 KB Output is correct
33 Correct 525 ms 71580 KB Output is correct
34 Correct 5 ms 1100 KB Output is correct
35 Correct 9 ms 1612 KB Output is correct
36 Correct 243 ms 25752 KB Output is correct
37 Correct 360 ms 38936 KB Output is correct
38 Correct 533 ms 51864 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 245 ms 37980 KB Output is correct
10 Correct 18 ms 4264 KB Output is correct
11 Correct 110 ms 21116 KB Output is correct
12 Correct 28 ms 6360 KB Output is correct
13 Correct 61 ms 12220 KB Output is correct
14 Correct 2 ms 460 KB Output is correct
15 Correct 2 ms 588 KB Output is correct
16 Correct 236 ms 32872 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Incorrect 1 ms 204 KB Tree @(3, 5) appears more than once: for edges on positions 0 and 2
19 Halted 0 ms 0 KB -