Submission #609753

# Submission time Handle Problem Language Result Execution time Memory
609753 2022-07-27T20:54:07 Z duality Fountain Parks (IOI21_parks) C++17
45 / 100
506 ms 26612 KB
#define DEBUG 0

#include <bits/stdc++.h>
using namespace std;

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------
#include "parks.h"

map<pii,int> M;
int parent[200000];
int find(int n) {
    if (parent[n] != n) parent[n] = find(parent[n]);
    return parent[n];
}
int construct_roads(vector<int> x,vector<int> y) {
    int i,n = x.size();
    vi u,v,a,b;
    for (i = 0; i < n; i++) M[mp(x[i],y[i])] = parent[i] = i;
    for (i = 0; i < n; i++) {
        if (((x[i]+y[i])/2) & 1) {
            if (M.count(mp(x[i]-2,y[i])) && (find(M[mp(x[i]-2,y[i])]) != find(i))) {
                u.pb(M[mp(x[i]-2,y[i])]),v.pb(i);
                parent[find(M[mp(x[i]-2,y[i])])] = find(i);
                a.pb(x[i]-1),b.pb(y[i]+1);
            }
            if (M.count(mp(x[i],y[i]-2)) && (find(M[mp(x[i],y[i]-2)]) != find(i))) {
                u.pb(M[mp(x[i],y[i]-2)]),v.pb(i);
                parent[find(M[mp(x[i],y[i]-2)])] = find(i);
                a.pb(x[i]-1),b.pb(y[i]-1);
            }
        }
        else {
            if (M.count(mp(x[i],y[i]-2)) && (find(M[mp(x[i],y[i]-2)]) != find(i))) {
                u.pb(M[mp(x[i],y[i]-2)]),v.pb(i);
                parent[find(M[mp(x[i],y[i]-2)])] = find(i);
                a.pb(x[i]+1),b.pb(y[i]-1);
            }
            if (M.count(mp(x[i]-2,y[i])) && (find(M[mp(x[i]-2,y[i])]) != find(i))) {
                u.pb(M[mp(x[i]-2,y[i])]),v.pb(i);
                parent[find(M[mp(x[i]-2,y[i])])] = find(i);
                a.pb(x[i]-1),b.pb(y[i]-1);
            }
        }
    }
    for (i = 0; i < n; i++) {
        if (find(i) != find(0)) return 0;
    }
    build(u,v,a,b);
    return 1;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 312 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 154 ms 13576 KB Output is correct
10 Correct 10 ms 2004 KB Output is correct
11 Correct 61 ms 8252 KB Output is correct
12 Correct 15 ms 2772 KB Output is correct
13 Correct 36 ms 5268 KB Output is correct
14 Correct 1 ms 316 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 159 ms 13604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 312 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 154 ms 13576 KB Output is correct
10 Correct 10 ms 2004 KB Output is correct
11 Correct 61 ms 8252 KB Output is correct
12 Correct 15 ms 2772 KB Output is correct
13 Correct 36 ms 5268 KB Output is correct
14 Correct 1 ms 316 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 159 ms 13604 KB Output is correct
17 Correct 1 ms 308 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 312 KB Output is correct
20 Incorrect 1 ms 308 KB Tree @(3, 7) appears more than once: for edges on positions 3 and 5
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 312 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 154 ms 13576 KB Output is correct
10 Correct 10 ms 2004 KB Output is correct
11 Correct 61 ms 8252 KB Output is correct
12 Correct 15 ms 2772 KB Output is correct
13 Correct 36 ms 5268 KB Output is correct
14 Correct 1 ms 316 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 159 ms 13604 KB Output is correct
17 Correct 1 ms 308 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 312 KB Output is correct
20 Incorrect 1 ms 308 KB Tree @(3, 7) appears more than once: for edges on positions 3 and 5
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 312 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 154 ms 13576 KB Output is correct
10 Correct 10 ms 2004 KB Output is correct
11 Correct 61 ms 8252 KB Output is correct
12 Correct 15 ms 2772 KB Output is correct
13 Correct 36 ms 5268 KB Output is correct
14 Correct 1 ms 316 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 159 ms 13604 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 433 ms 26472 KB Output is correct
21 Correct 424 ms 26504 KB Output is correct
22 Correct 417 ms 26480 KB Output is correct
23 Correct 342 ms 22712 KB Output is correct
24 Correct 258 ms 16988 KB Output is correct
25 Correct 410 ms 20148 KB Output is correct
26 Correct 396 ms 20276 KB Output is correct
27 Correct 416 ms 26516 KB Output is correct
28 Correct 452 ms 26604 KB Output is correct
29 Correct 462 ms 26552 KB Output is correct
30 Correct 482 ms 26492 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 21 ms 2588 KB Output is correct
33 Correct 84 ms 8696 KB Output is correct
34 Correct 398 ms 26552 KB Output is correct
35 Correct 12 ms 1512 KB Output is correct
36 Correct 67 ms 5576 KB Output is correct
37 Correct 164 ms 10452 KB Output is correct
38 Correct 167 ms 11212 KB Output is correct
39 Correct 234 ms 15008 KB Output is correct
40 Correct 329 ms 18736 KB Output is correct
41 Correct 400 ms 22692 KB Output is correct
42 Correct 492 ms 26512 KB Output is correct
43 Correct 1 ms 316 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 1 ms 312 KB Output is correct
46 Correct 0 ms 316 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 0 ms 312 KB Output is correct
50 Correct 0 ms 280 KB Output is correct
51 Correct 1 ms 212 KB Output is correct
52 Correct 0 ms 212 KB Output is correct
53 Correct 1 ms 212 KB Output is correct
54 Correct 2 ms 468 KB Output is correct
55 Correct 3 ms 612 KB Output is correct
56 Correct 166 ms 13620 KB Output is correct
57 Correct 292 ms 19432 KB Output is correct
58 Correct 266 ms 19384 KB Output is correct
59 Correct 1 ms 212 KB Output is correct
60 Correct 1 ms 212 KB Output is correct
61 Correct 1 ms 212 KB Output is correct
62 Correct 356 ms 26612 KB Output is correct
63 Correct 374 ms 26492 KB Output is correct
64 Correct 384 ms 26380 KB Output is correct
65 Correct 5 ms 724 KB Output is correct
66 Correct 8 ms 1108 KB Output is correct
67 Correct 171 ms 13616 KB Output is correct
68 Correct 318 ms 20132 KB Output is correct
69 Correct 448 ms 26460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 312 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 154 ms 13576 KB Output is correct
10 Correct 10 ms 2004 KB Output is correct
11 Correct 61 ms 8252 KB Output is correct
12 Correct 15 ms 2772 KB Output is correct
13 Correct 36 ms 5268 KB Output is correct
14 Correct 1 ms 316 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 159 ms 13604 KB Output is correct
17 Correct 399 ms 26532 KB Output is correct
18 Correct 406 ms 26544 KB Output is correct
19 Correct 451 ms 26564 KB Output is correct
20 Correct 503 ms 26008 KB Output is correct
21 Correct 425 ms 23280 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 50 ms 5072 KB Output is correct
24 Correct 25 ms 2752 KB Output is correct
25 Correct 103 ms 7716 KB Output is correct
26 Correct 216 ms 12364 KB Output is correct
27 Correct 195 ms 13516 KB Output is correct
28 Correct 277 ms 16884 KB Output is correct
29 Correct 415 ms 20044 KB Output is correct
30 Correct 416 ms 23236 KB Output is correct
31 Correct 506 ms 26564 KB Output is correct
32 Correct 447 ms 26532 KB Output is correct
33 Correct 362 ms 26532 KB Output is correct
34 Correct 5 ms 852 KB Output is correct
35 Correct 9 ms 1364 KB Output is correct
36 Correct 185 ms 13640 KB Output is correct
37 Correct 311 ms 20132 KB Output is correct
38 Correct 476 ms 26528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 312 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 154 ms 13576 KB Output is correct
10 Correct 10 ms 2004 KB Output is correct
11 Correct 61 ms 8252 KB Output is correct
12 Correct 15 ms 2772 KB Output is correct
13 Correct 36 ms 5268 KB Output is correct
14 Correct 1 ms 316 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 159 ms 13604 KB Output is correct
17 Correct 1 ms 308 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 312 KB Output is correct
20 Incorrect 1 ms 308 KB Tree @(3, 7) appears more than once: for edges on positions 3 and 5
21 Halted 0 ms 0 KB -