Submission #1077470

# Submission time Handle Problem Language Result Execution time Memory
1077470 2024-08-27T07:32:58 Z danikoynov Amusement Park (JOI17_amusement_park) C++14
10 / 100
19 ms 5172 KB
#include "Joi.h"


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

const int MAXN = 10010, MAXBIT = 60;
vector < int > adj[MAXN];
int used[MAXN], acord[MAXN];
vector < int > ord;

void dfs(int v, ll X, int bit)
{
  used[v] = 1;
  acord[v] = bit;
  MessageBoard(v, ((X & ((ll)(1) << bit)) > 0));
  ord.push_back(v);
  for (int u : adj[v])
  { 
    if (used[u])
      continue;
    dfs(u, X, (bit + 1) % MAXBIT);
    ord.push_back(v);
  }
}

void build_tree(int N, int M, int A[], int B[], ll X)
{
  for (int i = 0; i < M; i ++)
  {
    adj[A[i]].push_back(B[i]);
    adj[B[i]].push_back(A[i]);
  }

  dfs(0, X, 0);

  ord.pop_back();
}
void Joi(int N, int M, int A[], int B[], long long X, int T) {
  build_tree(N, M, A, B, X);
}
#include "Ioi.h"

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

const int MAXN = 10010, MAXBIT = 60;
vector < int > graph[MAXN];
int marked[MAXN], linked[MAXN];
vector < int > path;

void dfs(int v, int bit)
{
  marked[v] = 1;
  linked[v] = bit;
  //MessageBoard(v, ((X & ((ll)(1) << bit)) > 0));
  path.push_back(v);
  for (int u : graph[v])
  { 
    if (marked[u])
      continue;
    dfs(u, (bit + 1) % MAXBIT);
    path.push_back(v);
  }
}

void build_tree(int N, int M, int A[], int B[])
{
  for (int i = 0; i < M; i ++)
  {
    graph[A[i]].push_back(B[i]);
    graph[B[i]].push_back(A[i]);
  }

  dfs(0, 0);

  path.pop_back();
}

int bit_val[MAXBIT];

long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) 
{
  build_tree(N, M, A, B);


  int pos = 0;
  while(path[pos] != P)
    pos ++;
  bit_val[linked[P]] = V;
  int ver = P;
  for (int step = 0; step < 120; step ++)
  {
    int nxt = (pos + 1) % (int)(path.size());
    //cout << "move from " << ver  << " " << path[nxt] <<endl;
    ver = path[nxt];
    bit_val[linked[ver]] = Move(ver);
    pos = nxt;
  }

  ll X = 0;
  for (int bit = 0; bit < MAXBIT; bit ++)
  {
    if (bit_val[bit] > 0)
      X |= ((ll)(1) << bit);
  }

  return X;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1308 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 19 ms 4708 KB Output is correct
2 Incorrect 17 ms 5148 KB Wrong Answer [7]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1308 KB Output is correct
2 Correct 1 ms 1296 KB Output is correct
3 Correct 0 ms 1312 KB Output is correct
4 Correct 2 ms 1960 KB Output is correct
5 Correct 2 ms 1864 KB Output is correct
6 Correct 2 ms 1860 KB Output is correct
7 Correct 2 ms 1856 KB Output is correct
8 Correct 2 ms 2108 KB Output is correct
9 Correct 8 ms 4748 KB Output is correct
10 Correct 8 ms 4676 KB Output is correct
11 Correct 7 ms 4688 KB Output is correct
12 Correct 0 ms 1308 KB Output is correct
13 Correct 1 ms 1312 KB Output is correct
14 Correct 0 ms 1300 KB Output is correct
15 Correct 2 ms 1308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 4724 KB Output is correct
2 Incorrect 16 ms 5164 KB Wrong Answer [7]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 16 ms 4716 KB Output is correct
2 Correct 16 ms 5172 KB Output is correct
3 Correct 16 ms 5168 KB Output is correct
4 Incorrect 9 ms 3552 KB Wrong Answer [7]
5 Halted 0 ms 0 KB -