Submission #1096242

# Submission time Handle Problem Language Result Execution time Memory
1096242 2024-10-04T06:55:55 Z LucaLucaM Amusement Park (JOI17_amusement_park) C++17
0 / 100
18 ms 4848 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>

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++) {
    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;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1296 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 4848 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1364 KB Output is correct
2 Correct 0 ms 1296 KB Output is correct
3 Correct 1 ms 1308 KB Output is correct
4 Correct 2 ms 1852 KB Output is correct
5 Incorrect 2 ms 1856 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 4632 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 4512 KB Output isn't correct
2 Halted 0 ms 0 KB -