Submission #134950

# Submission time Handle Problem Language Result Execution time Memory
134950 2019-07-23T13:16:17 Z Just_Solve_The_Problem Amusement Park (JOI17_amusement_park) C++17
28 / 100
34 ms 4872 KB
#include <bits/stdc++.h>
#include "Joi.h"

#define ll long long

using namespace std;

const int maxn = (int)1e4 + 7;

static vector <int> gr[maxn];
static int used[maxn], d[maxn];
static int n, cur;
static ll x;

void dfs(int v) {
  used[v] = 1;
  MessageBoard(v, (x >> cur) & 1);
  cur++;
  if (cur >= 60) cur -= 60;
  for (int to : gr[v]) {
    if (used[to]) continue;
    dfs(to);
  }
}

void Joi(int N, int M, int A[], int B[], long long X, int T) {
  n = N;
  x = X;
  for (int i = 0; i < M; i++) {
    gr[A[i]].push_back(B[i]);
    gr[B[i]].push_back(A[i]);
  }
  for (int i = 0; i < n; i++) {
    used[i] = 0;
  }
  dfs(0);
}
#include <bits/stdc++.h>
#include "Ioi.h"

#define ll long long

using namespace std;

const int maxn = (int)1e4 + 7;

static int used[maxn], d[maxn], pr[maxn];
static vector <int> vec, gr[maxn];
static int n;
static ll x;
static int cur = -1;
static int ti[2][maxn], tiktak;
static int tin[maxn], tout[maxn], pos[maxn];

void dfs2(int v) {
  used[v] = 1;
  tin[v] = ++tiktak;
  pos[tin[v]] = v;
  if (ti[0][v] == -1) ti[0][v] = ti[1][v] = vec.size();
  vec.push_back(v);
  cur++;
  if (cur >= 60) cur -= 60;
  d[v] = cur;
  for (int to : gr[v]) {
    if (used[to]) continue;
    pr[to] = v;
    dfs2(to);
    ti[1][v] = vec.size();
    vec.push_back(v);
  }
  tout[v] = tiktak;
}

bool upper(int a, int b) {
  return tin[a] <= tin[b] && tout[a] >= tout[b];
}

long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {
  memset(ti, -1, sizeof ti);
  n = N;
  for (int i = 0; i < M; i++) {
    gr[A[i]].push_back(B[i]);
    gr[B[i]].push_back(A[i]);
  }
  for (int i = 0; i < n; i++) {
    used[i] = 0;
  }
  dfs2(0);
  for (int i = 0; i < n; i++) {
    used[i] = 0;
  }
  used[P] = V;
  set <int> S;
  int temp = cur;
  cur = P;
  int i = ti[0][P];
  vector <int> asd = {P};
  while (S.size() < 60) {
    S.insert(d[vec[i]]);
    if (cur != vec[i]) {
      asd.push_back(vec[i]);
    }
    cur = vec[i];
    if (used[vec[i]])
      x |= (1LL << d[vec[i]]);
    if (vec[i] == pos[n]) break;
    i++;
  }
  // work
  if (S.size() < 60) {
    // cur -> P
    S.clear();
    cur = P;
    while (!upper(cur, pos[n])) {
      used[pr[cur]] = Move(pr[cur]);
      cur = pr[cur];
    }
    asd.clear();
    temp = pos[n];
    while (temp != cur) {
      asd.push_back(temp);
      temp = pr[temp];
    }
    for (int j = asd.size() - 1; j >= 0; j--) {
      used[asd[j]] = Move(asd[j]);
    }
    cur = pos[n];
    i = ti[0][pos[n]];
    while (S.size() < 60) {
      S.insert(d[vec[i]]);
      if (cur != vec[i]) used[vec[i]] = Move(vec[i]);
      cur = vec[i];
      if (used[vec[i]])
        x |= (1LL << d[vec[i]]);
      if (i == 0) break;
      i--;
    }
  } else {
    cur = P;
    for (int to : asd) {
      if (cur != to) used[to] = Move(to);
      cur = to;
      if (used[to])
        x |= (1LL << d[to]);
    }
  }
  //cerr << x << endl;
  return x;
}

Compilation message

Joi.cpp:11:24: warning: 'd' defined but not used [-Wunused-variable]
 static int used[maxn], d[maxn];
                        ^
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1628 KB Output is correct
2 Correct 4 ms 1268 KB Output is correct
3 Correct 4 ms 1404 KB Output is correct
4 Correct 5 ms 1268 KB Output is correct
5 Correct 4 ms 1268 KB Output is correct
6 Correct 4 ms 1504 KB Output is correct
7 Correct 5 ms 1652 KB Output is correct
8 Correct 4 ms 1572 KB Output is correct
9 Correct 5 ms 1712 KB Output is correct
10 Correct 4 ms 1268 KB Output is correct
11 Correct 8 ms 1736 KB Output is correct
12 Correct 4 ms 1532 KB Output is correct
13 Correct 4 ms 1404 KB Output is correct
14 Correct 4 ms 1492 KB Output is correct
15 Correct 4 ms 1404 KB Output is correct
16 Correct 4 ms 1652 KB Output is correct
17 Correct 5 ms 1492 KB Output is correct
18 Correct 4 ms 1404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 4872 KB Output is correct
2 Correct 33 ms 4864 KB Output is correct
3 Correct 32 ms 4864 KB Output is correct
4 Correct 20 ms 3480 KB Output is correct
5 Correct 22 ms 3884 KB Output is correct
6 Correct 20 ms 3736 KB Output is correct
7 Correct 20 ms 3736 KB Output is correct
8 Correct 20 ms 3744 KB Output is correct
9 Correct 20 ms 3792 KB Output is correct
10 Correct 18 ms 3620 KB Output is correct
11 Correct 18 ms 3484 KB Output is correct
12 Correct 18 ms 3448 KB Output is correct
13 Correct 19 ms 3336 KB Output is correct
14 Correct 20 ms 3432 KB Output is correct
15 Correct 20 ms 3360 KB Output is correct
16 Correct 20 ms 3488 KB Output is correct
17 Correct 20 ms 3352 KB Output is correct
18 Correct 20 ms 3336 KB Output is correct
19 Correct 20 ms 3428 KB Output is correct
20 Correct 17 ms 3716 KB Output is correct
21 Correct 17 ms 3736 KB Output is correct
22 Correct 20 ms 3492 KB Output is correct
23 Correct 20 ms 3792 KB Output is correct
24 Correct 20 ms 3608 KB Output is correct
25 Correct 20 ms 3736 KB Output is correct
26 Correct 20 ms 3812 KB Output is correct
27 Correct 20 ms 3744 KB Output is correct
28 Correct 20 ms 3744 KB Output is correct
29 Correct 20 ms 3752 KB Output is correct
30 Correct 20 ms 3716 KB Output is correct
31 Correct 5 ms 1396 KB Output is correct
32 Correct 4 ms 1268 KB Output is correct
33 Correct 4 ms 1536 KB Output is correct
34 Correct 4 ms 1268 KB Output is correct
35 Correct 4 ms 1396 KB Output is correct
36 Correct 4 ms 1268 KB Output is correct
37 Correct 5 ms 1404 KB Output is correct
38 Correct 4 ms 1268 KB Output is correct
39 Correct 4 ms 1268 KB Output is correct
40 Correct 5 ms 1500 KB Output is correct
41 Correct 4 ms 1268 KB Output is correct
42 Correct 5 ms 1404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1268 KB Output is correct
2 Correct 6 ms 1268 KB Output is correct
3 Correct 4 ms 1404 KB Output is correct
4 Correct 6 ms 1700 KB Output is correct
5 Correct 6 ms 1876 KB Output is correct
6 Correct 6 ms 1824 KB Output is correct
7 Correct 6 ms 1696 KB Output is correct
8 Correct 6 ms 1888 KB Output is correct
9 Correct 16 ms 3992 KB Output is correct
10 Correct 17 ms 4300 KB Output is correct
11 Correct 17 ms 3992 KB Output is correct
12 Correct 4 ms 1524 KB Output is correct
13 Correct 4 ms 1268 KB Output is correct
14 Correct 4 ms 1408 KB Output is correct
15 Correct 4 ms 1268 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 4864 KB Output is correct
2 Partially correct 33 ms 4788 KB Partially correct
3 Partially correct 32 ms 4704 KB Partially correct
4 Correct 20 ms 3380 KB Output is correct
5 Partially correct 20 ms 3920 KB Partially correct
6 Correct 20 ms 3736 KB Output is correct
7 Correct 20 ms 3792 KB Output is correct
8 Correct 20 ms 3632 KB Output is correct
9 Correct 20 ms 3716 KB Output is correct
10 Correct 19 ms 3336 KB Output is correct
11 Correct 19 ms 3480 KB Output is correct
12 Correct 18 ms 3216 KB Output is correct
13 Correct 19 ms 3308 KB Output is correct
14 Correct 20 ms 3368 KB Output is correct
15 Correct 20 ms 3352 KB Output is correct
16 Correct 20 ms 3480 KB Output is correct
17 Correct 20 ms 3460 KB Output is correct
18 Correct 20 ms 3512 KB Output is correct
19 Correct 20 ms 3480 KB Output is correct
20 Incorrect 16 ms 3768 KB Output isn't correct
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 32 ms 4736 KB Output is correct
2 Correct 34 ms 4736 KB Output is correct
3 Incorrect 33 ms 4844 KB Output isn't correct
4 Halted 0 ms 0 KB -