답안 #1096245

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1096245 2024-10-04T06:58:31 Z LucaLucaM Amusement Park (JOI17_amusement_park) C++17
0 / 100
23 ms 4652 KB
#include "Joi.h"
#include <vector>
#include <algorithm>

using ll = long long;
const int NMAX = 10'000;

std::vector<int> g[NMAX + 1];
int value[NMAX + 1];
bool vis[NMAX + 1];

std::vector<int> order;
void dfs(int u) {
  order.push_back(u);
  vis[u] = true;
  for (const auto &v : g[u]) {
    if (!vis[v]) {
      dfs(v);
    }
  }
}


void Joi(int n, int m, int a[], int b[], long long X, int T) {
  for (int i = 0; i < m; i++) {
    g[a[i]].push_back(b[i]);
    g[b[i]].push_back(a[i]);
  }
  for (int i = 0; i < n; i++) {
    std::sort(g[i].begin(), g[i].end());
  }
  dfs(0);
  for (int i = 0; i < 60; i++) {
    value[order[i]] = ((ll) X >> i) & 1LL;
  }
  for (int i = 0; i < n; i++) {
    MessageBoard(i, value[i]);
  }
}
#include "Ioi.h"
#include <vector>
#include <algorithm>
#include <cassert>

using ll = long long;
const int NMAX = 10'000;

std::vector<int> g[NMAX + 1];
int value[NMAX + 1];
bool vis[NMAX + 1];
int parent[NMAX + 1];

std::vector<int> order;
void dfs(int u) {
  order.push_back(u);
  vis[u] = true;
  for (const auto &v : g[u]) {
    if (!vis[v]) {
      parent[v] = u;
      dfs(v);
    }
  }
}

bool hasSon(int u, int v) { // v e fiu al lui u?
  for (const auto &w : g[u]) {
    if (v == w) {
      return true;
    }
  }
  return false;
}

long long Ioi(int n, int m, int a[], int b[], int P, int V, int T) {
  for (int i = 0; i < m; i++) {
    g[a[i]].push_back(b[i]);
    g[b[i]].push_back(a[i]);
  }
  for (int i = 0; i < n; i++) {
    assert(!vis[i]);
    std::sort(g[i].begin(), g[i].end());
  }
  dfs(0);
  int u = P;
  ll answer = 0;
  if (u == 0) {
    Move(g[0][0]);
    answer = Move(0);
  }
  while (u != 0) {
    u = parent[u];
    answer = Move(u);
  }
  for (int i = 1; i < 60; i++) {
    while (!hasSon(u, order[i])) {
      u = parent[u];
    }
    if (Move(order[i])) {
      answer |= (1LL << i);
    }
    u = order[i];
  }
  return answer;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 1304 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 19 ms 4636 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1296 KB Output is correct
2 Correct 0 ms 1336 KB Output is correct
3 Correct 0 ms 1308 KB Output is correct
4 Correct 2 ms 1856 KB Output is correct
5 Incorrect 2 ms 1860 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 23 ms 4592 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 20 ms 4652 KB Output isn't correct
2 Halted 0 ms 0 KB -