Submission #228051

# Submission time Handle Problem Language Result Execution time Memory
228051 2020-04-29T17:50:33 Z qkxwsm Amusement Park (JOI17_amusement_park) C++14
18 / 100
41 ms 3808 KB
#include "Joi.h"
#include <bits/stdc++.h>

using namespace std;

template<class T, class U>
void ckmin(T &a, U b)
{
    if (a > b) a = b;
}

template<class T, class U>
void ckmax(T &a, U b)
{
    if (a < b) a = b;
}

#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define SZ(x) ((int) (x).size())
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

static const int MAXN = 10013;

static int N;
static vi edge[MAXN];
static int dsu[MAXN];

static int get(int u)
{
    return (u == dsu[u] ? u : dsu[u] = get(dsu[u]));
}
static bool merge(int u, int v)
{
    u = get(u);
    v = get(v);
    if (u == v)
    {
        return false;
    }
    dsu[u] = v;
    return true;
}

void Joi(int n, int m, int e1[], int e2[], ll val, int subtask)
{
    N = n;
    iota(dsu, dsu + N, 0);
    FOR(i, 0, m)
    {
        int u = e1[i], v = e2[i];
        if (merge(u, v))
        {
            edge[u].PB(v);
            edge[v].PB(u);
            // cerr << "edge " << u << ' ' << v << endl;
        }
    }
    // cerr << "ALIVE\n";
    FOR(i, 0, N)
    {
        int cur = 0;
        if (i < 60 && (val & (1ll << i)) > 0)
        {
            cur = 1;
        }
        // cerr << "message " << i << ' ' << cur << endl;
        MessageBoard(i, cur);
    }
}
#include "Ioi.h"
#include <bits/stdc++.h>

using namespace std;

template<class T, class U>
void ckmin(T &a, U b)
{
    if (a > b) a = b;
}

template<class T, class U>
void ckmax(T &a, U b)
{
    if (a < b) a = b;
}

#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define SZ(x) ((int) (x).size())
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

static const int MAXN = 10013;

static int N;
static vi edge[MAXN];
static int dsu[MAXN];
static bool val[MAXN];
static ll ans;

static int get(int u)
{
    return (u == dsu[u] ? u : dsu[u] = get(dsu[u]));
}
static bool merge(int u, int v)
{
    u = get(u);
    v = get(v);
    if (u == v)
    {
        return false;
    }
    dsu[u] = v;
    return true;
}
void dfs(int u, int p)
{
    for (int v : edge[u])
    {
        if (v == p) continue;
        val[v] = Move(v);
        dfs(v, u);
        Move(u);
    }
}

ll Ioi(int n, int m, int e1[], int e2[], int st, int va, int subtask)
{
    N = n;
    iota(dsu, dsu + N, 0);
    FOR(i, 0, m)
    {
        int u = e1[i], v = e2[i];
        if (merge(u, v))
        {
            edge[u].PB(v);
            edge[v].PB(u);
            // cerr << "edge " << u << ' ' << v << endl;
        }
    }
    val[st] = va;
    dfs(st, N);
    FOR(i, 0, 60)
    {
        if (val[i])
        {
            ans += (1ll << i);
        }
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 9 ms 1288 KB Output is correct
2 Correct 10 ms 1524 KB Output is correct
3 Correct 10 ms 1404 KB Output is correct
4 Correct 10 ms 1292 KB Output is correct
5 Correct 9 ms 1296 KB Output is correct
6 Correct 10 ms 1296 KB Output is correct
7 Correct 10 ms 1540 KB Output is correct
8 Correct 10 ms 1536 KB Output is correct
9 Correct 10 ms 1540 KB Output is correct
10 Correct 10 ms 1544 KB Output is correct
11 Correct 13 ms 1716 KB Output is correct
12 Correct 9 ms 1392 KB Output is correct
13 Correct 10 ms 1424 KB Output is correct
14 Correct 10 ms 1548 KB Output is correct
15 Correct 11 ms 1424 KB Output is correct
16 Correct 10 ms 1512 KB Output is correct
17 Correct 10 ms 1544 KB Output is correct
18 Correct 10 ms 1548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 37 ms 3800 KB Output is correct
2 Correct 38 ms 3800 KB Output is correct
3 Correct 41 ms 3808 KB Output is correct
4 Correct 27 ms 2900 KB Output is correct
5 Correct 27 ms 3420 KB Output is correct
6 Correct 27 ms 3184 KB Output is correct
7 Correct 27 ms 3188 KB Output is correct
8 Correct 27 ms 3184 KB Output is correct
9 Correct 25 ms 3188 KB Output is correct
10 Correct 26 ms 3016 KB Output is correct
11 Correct 25 ms 3252 KB Output is correct
12 Correct 25 ms 3084 KB Output is correct
13 Correct 25 ms 2956 KB Output is correct
14 Correct 25 ms 2872 KB Output is correct
15 Correct 27 ms 3068 KB Output is correct
16 Correct 27 ms 3068 KB Output is correct
17 Correct 27 ms 3048 KB Output is correct
18 Correct 28 ms 3072 KB Output is correct
19 Correct 26 ms 3056 KB Output is correct
20 Correct 23 ms 3364 KB Output is correct
21 Correct 23 ms 3132 KB Output is correct
22 Correct 27 ms 3132 KB Output is correct
23 Correct 28 ms 3200 KB Output is correct
24 Correct 26 ms 3140 KB Output is correct
25 Correct 27 ms 3192 KB Output is correct
26 Correct 27 ms 3200 KB Output is correct
27 Correct 27 ms 3188 KB Output is correct
28 Correct 27 ms 3184 KB Output is correct
29 Correct 26 ms 2852 KB Output is correct
30 Correct 27 ms 3204 KB Output is correct
31 Correct 10 ms 1292 KB Output is correct
32 Correct 10 ms 1288 KB Output is correct
33 Correct 10 ms 1540 KB Output is correct
34 Correct 10 ms 1288 KB Output is correct
35 Correct 9 ms 1288 KB Output is correct
36 Correct 10 ms 1288 KB Output is correct
37 Correct 10 ms 1288 KB Output is correct
38 Correct 11 ms 1416 KB Output is correct
39 Correct 10 ms 1288 KB Output is correct
40 Correct 9 ms 1548 KB Output is correct
41 Correct 10 ms 1292 KB Output is correct
42 Correct 9 ms 1292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 1516 KB Output is correct
2 Correct 10 ms 1528 KB Output is correct
3 Correct 9 ms 1536 KB Output is correct
4 Incorrect 12 ms 1732 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 37 ms 3796 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 41 ms 3800 KB Output isn't correct
2 Halted 0 ms 0 KB -