제출 #134950

#제출 시각아이디문제언어결과실행 시간메모리
134950Just_Solve_The_ProblemAmusement Park (JOI17_amusement_park)C++17
28 / 100
34 ms4872 KiB
#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;
}

컴파일 시 표준 에러 (stderr) 메시지

Joi.cpp:11:24: warning: 'd' defined but not used [-Wunused-variable]
 static int used[maxn], d[maxn];
                        ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...