답안 #134975

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
134975 2019-07-23T13:41:06 Z Just_Solve_The_Problem Amusement Park (JOI17_amusement_park) C++17
0 / 100
37 ms 4744 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], nwgr[maxn];
static int n;
static ll x;
static int cur = -1;

void dfs2(int v) {
  used[v] = 1;
  cur++;
  if (cur >= 60) cur -= 60;
  d[v] = cur;
  for (int to : gr[v]) {
    if (used[to]) continue;
    pr[to] = v;
    nwgr[v].push_back(to);
    dfs2(to);
  }
}

set <int> S;
int us[maxn];

void dfs3(int v) {
  if (S.size() >= 60) return ;
  us[v] = 1;
  S.insert(d[v]);
  if (used[v])
    x |= (1LL << d[v]);
  int ind = -1;
  for (int i = 0; i < nwgr[v].size(); i++) {
    int to = nwgr[v][i];
    if (us[to]) ind = i;
  }
  for (int i = ind + 1; i < nwgr[v].size(); i++) {
    int to = nwgr[v][i];
    used[to] = Move(to);
    dfs3(to);
    if (S.size() >= 60) return ;
    Move(v);
  }
  for (int i = ind - 1; i >= 0; i--) {
    int to = nwgr[v][i];
    used[to] = Move(to);
    dfs3(to);
    if (S.size() >= 60) return ;
    Move(v);
  }
}

long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {
  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;
  while (S.size() < 60) {
    dfs3(P);
    if (S.size() >= 60) break;
    P = pr[P];
    used[P] = Move(P);
  }
  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];
                        ^

Ioi.cpp: In function 'void dfs3(int)':
Ioi.cpp:39:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < nwgr[v].size(); i++) {
                   ~~^~~~~~~~~~~~~~~~
Ioi.cpp:43:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = ind + 1; i < nwgr[v].size(); i++) {
                         ~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 1760 KB Do not print anything on standard output.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 33 ms 4624 KB Do not print anything on standard output.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 1520 KB Do not print anything on standard output.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 37 ms 4684 KB Do not print anything on standard output.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 33 ms 4744 KB Do not print anything on standard output.
2 Halted 0 ms 0 KB -