답안 #134872

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
134872 2019-07-23T11:07:07 Z Just_Solve_The_Problem Amusement Park (JOI17_amusement_park) C++17
0 / 100
19 ms 3832 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]);
  }
  dfs(0);
  cerr << X << endl;
}
#include <bits/stdc++.h>
#include "Ioi.h"

#define ll long long

using namespace std;

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

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

void dfs2(int v) {
  used[v] = 1;
  vec.push_back(v);
  d[v] = cur;
  cur++;
  if (cur >= 60) cur -= 60;
  for (int to : gr[v]) {
    if (used[to]) continue;
    dfs2(to);
    vec.push_back(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]);
  }
  dfs2(0);
  for (int i = 0; i < n; i++) {
    used[i] = 0;
  }
  used[P] = V;
  int ind = 0;
  for (int i = 0; i < vec.size(); i++) {
    if (vec[i] == P) {
      ind = i;
      break;
    }
  }
  int cnt = 0;
  set <int> S;
  cur = P;
  for (int i = ind; i < vec.size(); i++) {
    S.insert(vec[i]);
    cnt++;
    if (S.size() >= 60) {
      break;
    }
  }
  if (S.size() >= 60 && cnt <= 120) {
    S.clear();
    for (int i = ind; i < vec.size(); i++) {
      int prv = S.size();
      S.insert(vec[i]);
      if (cur != vec[i]) used[vec[i]] = Move(vec[i]);
      cur = vec[i];
      x |= ((used[vec[i]] * 1LL) << d[vec[i]]);
      if (S.size() >= 60) break;
    }
  } else {
    for (int i = vec.size() - 1; i >= 0; i--) {
      if (vec[i] == P) {
        ind = i;
        break;
      }
    }
    S.clear();
    for (int i = ind; i >= 0; i--) {
      S.insert(vec[i]);
      if (cur != vec[i]) used[vec[i]] = Move(vec[i]);
      cur = vec[i];
      x |= ((used[vec[i]] * 1LL) << d[vec[i]]);
      if (S.size() >= 60) break;
    }
  }
  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 'long long int Ioi(int, int, int*, int*, int, int, int)':
Ioi.cpp:41:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < vec.size(); i++) {
                   ~~^~~~~~~~~~~~
Ioi.cpp:50:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = ind; i < vec.size(); i++) {
                     ~~^~~~~~~~~~~~
Ioi.cpp:59:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = ind; i < vec.size(); i++) {
                       ~~^~~~~~~~~~~~
Ioi.cpp:60:11: warning: unused variable 'prv' [-Wunused-variable]
       int prv = S.size();
           ^~~
Ioi.cpp: At global scope:
Ioi.cpp:10:12: warning: 'pr' defined but not used [-Wunused-variable]
 static int pr[maxn], used[maxn], d[maxn];
            ^~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 1364 KB Do not print anything on standard output.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 19 ms 3824 KB Do not print anything on standard output.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 1264 KB Do not print anything on standard output.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 19 ms 3768 KB Do not print anything on standard output.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 19 ms 3832 KB Do not print anything on standard output.
2 Halted 0 ms 0 KB -