답안 #257431

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
257431 2020-08-04T09:11:26 Z islingr Amusement Park (JOI17_amusement_park) C++17
80 / 100
33 ms 4688 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 sz[N];

void dfs_sz(int u) {
  sz[u] = 1;
  for (int &v : g[u]) {
    g[v].erase(find(all(g[v]), u));
    dfs_sz(v);
    sz[u] += sz[v];
    if (sz[g[u][0]] < sz[v]) swap(v, g[u][0]);
  }
}

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

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]);
    }
  }
  dfs_sz(0); x = X; dfs(0);
}
#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 = 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 p[N], sz[N], in[N], timer = 0;
void dfs_sz(int u) {
  sz[u] = 1;
  for (int &v : g[u]) {
    g[v].erase(find(all(g[v]), u));
    dfs_sz(v);
    sz[u] += sz[v];
    if (sz[g[u][0]] < sz[v]) swap(v, g[u][0]);
  }
}

void init(int u) {
  in[u] = timer;
  if (++timer == B) timer = 0;
  for (int v : g[u]) {
    p[v] = u;
    init(v);
  }
}

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

ll 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]);
    }
  }
  dfs_sz(0); init(0);
  while (sz[P] < B) V = Move(p[P]), P = p[P];
  dfs(P, V);
  return x;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1780 KB Output is correct
2 Correct 2 ms 1780 KB Output is correct
3 Correct 2 ms 1552 KB Output is correct
4 Correct 3 ms 1796 KB Output is correct
5 Correct 2 ms 1788 KB Output is correct
6 Correct 2 ms 1544 KB Output is correct
7 Correct 2 ms 1552 KB Output is correct
8 Correct 2 ms 1760 KB Output is correct
9 Correct 2 ms 1756 KB Output is correct
10 Correct 2 ms 1544 KB Output is correct
11 Correct 6 ms 1976 KB Output is correct
12 Correct 2 ms 1544 KB Output is correct
13 Correct 2 ms 1760 KB Output is correct
14 Correct 3 ms 1752 KB Output is correct
15 Correct 2 ms 1552 KB Output is correct
16 Correct 2 ms 1760 KB Output is correct
17 Correct 2 ms 1752 KB Output is correct
18 Correct 2 ms 1760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 4284 KB Output is correct
2 Correct 33 ms 4384 KB Output is correct
3 Correct 31 ms 4132 KB Output is correct
4 Correct 20 ms 3384 KB Output is correct
5 Correct 18 ms 4012 KB Output is correct
6 Correct 17 ms 3756 KB Output is correct
7 Correct 18 ms 3948 KB Output is correct
8 Correct 20 ms 3756 KB Output is correct
9 Correct 22 ms 3888 KB Output is correct
10 Correct 15 ms 3504 KB Output is correct
11 Correct 17 ms 3504 KB Output is correct
12 Correct 19 ms 3412 KB Output is correct
13 Correct 21 ms 3220 KB Output is correct
14 Correct 22 ms 3644 KB Output is correct
15 Correct 20 ms 3620 KB Output is correct
16 Correct 20 ms 3500 KB Output is correct
17 Correct 23 ms 3500 KB Output is correct
18 Correct 18 ms 3372 KB Output is correct
19 Correct 18 ms 3628 KB Output is correct
20 Correct 14 ms 4012 KB Output is correct
21 Correct 14 ms 4096 KB Output is correct
22 Correct 17 ms 3628 KB Output is correct
23 Correct 20 ms 3900 KB Output is correct
24 Correct 23 ms 3824 KB Output is correct
25 Correct 17 ms 3756 KB Output is correct
26 Correct 24 ms 3908 KB Output is correct
27 Correct 20 ms 3884 KB Output is correct
28 Correct 18 ms 4124 KB Output is correct
29 Correct 17 ms 3856 KB Output is correct
30 Correct 18 ms 3872 KB Output is correct
31 Correct 2 ms 1544 KB Output is correct
32 Correct 2 ms 1768 KB Output is correct
33 Correct 2 ms 1756 KB Output is correct
34 Correct 2 ms 1544 KB Output is correct
35 Correct 2 ms 1544 KB Output is correct
36 Correct 2 ms 1544 KB Output is correct
37 Correct 2 ms 1792 KB Output is correct
38 Correct 2 ms 1776 KB Output is correct
39 Correct 2 ms 1536 KB Output is correct
40 Correct 2 ms 1776 KB Output is correct
41 Correct 1 ms 1544 KB Output is correct
42 Correct 2 ms 1780 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1768 KB Output is correct
2 Correct 2 ms 1672 KB Output is correct
3 Correct 2 ms 1672 KB Output is correct
4 Correct 5 ms 2232 KB Output is correct
5 Correct 4 ms 2132 KB Output is correct
6 Correct 4 ms 2100 KB Output is correct
7 Correct 4 ms 2228 KB Output is correct
8 Correct 4 ms 2100 KB Output is correct
9 Correct 14 ms 4684 KB Output is correct
10 Correct 14 ms 4524 KB Output is correct
11 Correct 14 ms 4688 KB Output is correct
12 Correct 2 ms 1772 KB Output is correct
13 Correct 2 ms 1672 KB Output is correct
14 Correct 1 ms 1776 KB Output is correct
15 Correct 2 ms 1544 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 4368 KB Output is correct
2 Correct 27 ms 4396 KB Output is correct
3 Partially correct 27 ms 4368 KB Partially correct
4 Correct 17 ms 3372 KB Output is correct
5 Partially correct 18 ms 4268 KB Partially correct
6 Correct 17 ms 3756 KB Output is correct
7 Correct 17 ms 3884 KB Output is correct
8 Correct 18 ms 3752 KB Output is correct
9 Correct 17 ms 3756 KB Output is correct
10 Correct 17 ms 3504 KB Output is correct
11 Correct 21 ms 3592 KB Output is correct
12 Correct 16 ms 3220 KB Output is correct
13 Correct 18 ms 3416 KB Output is correct
14 Correct 20 ms 3232 KB Output is correct
15 Correct 18 ms 3620 KB Output is correct
16 Correct 18 ms 3372 KB Output is correct
17 Correct 24 ms 3732 KB Output is correct
18 Partially correct 18 ms 3500 KB Partially correct
19 Correct 17 ms 3372 KB Output is correct
20 Correct 16 ms 4244 KB Output is correct
21 Correct 15 ms 4096 KB Output is correct
22 Correct 17 ms 3884 KB Output is correct
23 Correct 17 ms 3884 KB Output is correct
24 Correct 18 ms 3940 KB Output is correct
25 Correct 18 ms 3884 KB Output is correct
26 Correct 19 ms 3904 KB Output is correct
27 Correct 18 ms 4168 KB Output is correct
28 Correct 17 ms 3628 KB Output is correct
29 Correct 16 ms 3608 KB Output is correct
30 Correct 18 ms 3792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 4364 KB Output is correct
2 Correct 28 ms 4372 KB Output is correct
3 Incorrect 31 ms 4364 KB Output isn't correct
4 Halted 0 ms 0 KB -