Submission #257390

# Submission time Handle Problem Language Result Execution time Memory
257390 2020-08-04T08:13:46 Z islingr Amusement Park (JOI17_amusement_park) C++17
28 / 100
36 ms 4380 KB
#include "Joi.h"
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define all(x) begin(x), end(x)

using ll = long long;

namespace {
const int N = 1 << 14, B = 60;
int nxt[N];
int head(int u) { return nxt[u] != u ? nxt[u] = head(nxt[u]) : u; }
bool unite(int u, int v) {
  u = head(u); v = head(v);
  if (u == v) return 0;
  nxt[u] = v; return 1;
}

vector<int> g[N]; int timer = 0; ll x;
void dfs(int u, int p) {
  MessageBoard(u, x >> timer & 1);
  ++timer; if (timer == B) timer = 0;
  for (int v : g[u]) if (v != p) dfs(v, u);
}
}

void Joi(int n, int m, int a[], int b[], ll X, int t) {
  rep(u, 0, n) nxt[u] = u;
  rep(e, 0, m) {
    if (unite(a[e], b[e])) {
      g[a[e]].push_back(b[e]);
      g[b[e]].push_back(a[e]);
    }
  }
  x = X; dfs(0, -1);
}
#include "Ioi.h"
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define all(x) begin(x), end(x)

using ll = int64_t;

namespace {
const int N = 1 << 14, B = 60;
int nxt[N];
int head(int u) { return nxt[u] != u ? nxt[u] = head(nxt[u]) : u; }
bool unite(int u, int v) {
  u = head(u); v = head(v);
  if (u == v) return 0;
  nxt[u] = v; return 1;
}

vector<int> g[N];
int p[N], in[N], out[N], timer = 0;
void init(int u, int p) {
  in[u] = timer++ % B;
  for (int v : g[u]) if (v != p) init(v, u);
}

ll U = (1ll << B) - 1, cur = 0, x = 0;
bool dfs(int u, int p, ll z) {
  cur |= 1ll << in[u];
  x |= z << in[u];
  if (cur == U) return true;
  for (int v : g[u]) {
    if (v == p) continue;
    if (dfs(v, u, Move(v))) return true;
    Move(u);
  }
  return false;
}
}

long long Ioi(int n, int m, int a[], int b[], int P, int V, int T) {
  rep(u, 0, n) nxt[u] = u;
  rep(e, 0, m) {
    if (unite(a[e], b[e])) {
      g[a[e]].push_back(b[e]);
      g[b[e]].push_back(a[e]);
    }
  }
  init(0, -1);
  dfs(P, -1, V);
  return x;
}

Compilation message

Ioi.cpp:21:18: warning: '{anonymous}::out' defined but not used [-Wunused-variable]
 int p[N], in[N], out[N], timer = 0;
                  ^~~
Ioi.cpp:21:5: warning: '{anonymous}::p' defined but not used [-Wunused-variable]
 int p[N], in[N], out[N], timer = 0;
     ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1776 KB Output is correct
2 Correct 2 ms 1672 KB Output is correct
3 Correct 3 ms 1768 KB Output is correct
4 Correct 2 ms 1544 KB Output is correct
5 Correct 2 ms 1676 KB Output is correct
6 Correct 2 ms 1772 KB Output is correct
7 Correct 2 ms 1680 KB Output is correct
8 Correct 2 ms 1760 KB Output is correct
9 Correct 2 ms 1760 KB Output is correct
10 Correct 2 ms 1544 KB Output is correct
11 Correct 5 ms 1876 KB Output is correct
12 Correct 2 ms 1680 KB Output is correct
13 Correct 2 ms 1892 KB Output is correct
14 Correct 2 ms 1552 KB Output is correct
15 Correct 2 ms 1764 KB Output is correct
16 Correct 2 ms 1552 KB Output is correct
17 Correct 2 ms 1760 KB Output is correct
18 Correct 3 ms 1760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 4160 KB Output is correct
2 Correct 28 ms 4004 KB Output is correct
3 Correct 27 ms 4004 KB Output is correct
4 Correct 17 ms 3244 KB Output is correct
5 Correct 17 ms 3756 KB Output is correct
6 Correct 17 ms 3652 KB Output is correct
7 Correct 16 ms 3516 KB Output is correct
8 Correct 17 ms 3872 KB Output is correct
9 Correct 17 ms 3772 KB Output is correct
10 Correct 15 ms 3636 KB Output is correct
11 Correct 15 ms 3392 KB Output is correct
12 Correct 15 ms 3336 KB Output is correct
13 Correct 15 ms 3336 KB Output is correct
14 Correct 16 ms 3312 KB Output is correct
15 Correct 17 ms 3260 KB Output is correct
16 Correct 17 ms 3260 KB Output is correct
17 Correct 17 ms 3260 KB Output is correct
18 Correct 17 ms 3260 KB Output is correct
19 Correct 19 ms 3260 KB Output is correct
20 Correct 14 ms 3828 KB Output is correct
21 Correct 14 ms 3864 KB Output is correct
22 Correct 16 ms 3560 KB Output is correct
23 Correct 17 ms 3644 KB Output is correct
24 Correct 17 ms 3544 KB Output is correct
25 Correct 17 ms 3772 KB Output is correct
26 Correct 19 ms 3880 KB Output is correct
27 Correct 19 ms 3772 KB Output is correct
28 Correct 17 ms 3872 KB Output is correct
29 Correct 15 ms 3492 KB Output is correct
30 Correct 17 ms 3544 KB Output is correct
31 Correct 2 ms 1544 KB Output is correct
32 Correct 2 ms 1672 KB Output is correct
33 Correct 2 ms 1680 KB Output is correct
34 Correct 2 ms 1776 KB Output is correct
35 Correct 2 ms 1544 KB Output is correct
36 Correct 2 ms 1788 KB Output is correct
37 Correct 2 ms 1784 KB Output is correct
38 Correct 2 ms 1672 KB Output is correct
39 Correct 2 ms 1672 KB Output is correct
40 Correct 2 ms 1784 KB Output is correct
41 Correct 2 ms 1544 KB Output is correct
42 Correct 2 ms 1784 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1544 KB Output is correct
2 Correct 2 ms 1772 KB Output is correct
3 Correct 2 ms 1672 KB Output is correct
4 Correct 4 ms 1860 KB Output is correct
5 Correct 4 ms 1860 KB Output is correct
6 Correct 3 ms 1988 KB Output is correct
7 Correct 3 ms 1860 KB Output is correct
8 Correct 3 ms 1860 KB Output is correct
9 Correct 14 ms 4372 KB Output is correct
10 Correct 14 ms 4380 KB Output is correct
11 Correct 13 ms 4156 KB Output is correct
12 Correct 1 ms 1672 KB Output is correct
13 Correct 2 ms 1544 KB Output is correct
14 Correct 1 ms 1788 KB Output is correct
15 Correct 1 ms 1544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 27 ms 4040 KB Partially correct
2 Correct 27 ms 4004 KB Output is correct
3 Partially correct 27 ms 4160 KB Partially correct
4 Correct 17 ms 3256 KB Output is correct
5 Partially correct 17 ms 4104 KB Partially correct
6 Partially correct 17 ms 3900 KB Partially correct
7 Partially correct 16 ms 3880 KB Partially correct
8 Partially correct 17 ms 3516 KB Partially correct
9 Partially correct 17 ms 3532 KB Partially correct
10 Correct 15 ms 3632 KB Output is correct
11 Correct 16 ms 3392 KB Output is correct
12 Correct 15 ms 3320 KB Output is correct
13 Partially correct 15 ms 3340 KB Partially correct
14 Partially correct 15 ms 3248 KB Partially correct
15 Correct 16 ms 3260 KB Output is correct
16 Correct 17 ms 3280 KB Output is correct
17 Correct 17 ms 3260 KB Output is correct
18 Partially correct 17 ms 3280 KB Partially correct
19 Partially correct 17 ms 3260 KB Partially correct
20 Incorrect 14 ms 3644 KB Output isn't correct
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 27 ms 4152 KB Output is correct
2 Incorrect 32 ms 4028 KB Output isn't correct
3 Halted 0 ms 0 KB -