Submission #341560

# Submission time Handle Problem Language Result Execution time Memory
341560 2020-12-30T02:57:14 Z KoD Amusement Park (JOI17_amusement_park) C++17
28 / 100
26 ms 3336 KB
#include "Joi.h"

void Joi(int N, int M, int A[], int B[], long long X, int T) {
  if (T <= 2) {
    for (int i = 0; i < 60; ++i) {
      MessageBoard(i, X >> i & 1);
    }
    for (int i = 60; i < N; ++i) {
      MessageBoard(i, 0);
    }
  }
  if (T == 3) {
    for (int i = 0; i < N; ++i) {
      const auto d = i % 60;
      MessageBoard(i, X >> d & 1);
    }
  }
}
#include "Ioi.h"
#include <vector>

namespace {

template <class T>
using Vec = std::vector<T>;

Vec<Vec<int>> graph;
Vec<int> value;

void write(const int u, const int p) {
  for (const auto v: graph[u]) {
    if (value[v] == -1) {
      value[v] = Move(v);
      write(v, u);
    }
  }
  if (p != -1) {
    Move(p);
  }
}

};

long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {
  graph.resize(N);
  value.resize(N, -1);
  for (int i = 0; i < M; ++i) {
    graph[A[i]].push_back(B[i]);
    graph[B[i]].push_back(A[i]);
  }
  value[P] = V;
  if (T <= 2) {
    write(P, -1);
    long long X = 0;
    for (int i = 0; i < 60; ++i) {
      if (value[i]) {
        X += (1ll << i);
      }
    }
    return X;
  }
  if (T == 3) {
    int goal = P / 60 * 60;
    if (goal + 60 > N) {
      goal -= 60;
    }
    while (P > goal) {
      for (const auto v: graph[P]) {
        if (v < P) {
          value[v] = Move(v);
          P = v;
          break;
        }
      }
    } 
    long long X = 0;
    for (int i = 0; i < 60; ++i) {
      if (value[P]) {
        X += (1ll << i);
      }
      for (const auto v: graph[P]) {
        if (v > P) {
          value[v] = Move(v);
          P = v;
          break;
        }
      }
    }
    return X;
  }
  return -1;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 932 KB Output is correct
2 Correct 0 ms 780 KB Output is correct
3 Correct 2 ms 748 KB Output is correct
4 Correct 0 ms 868 KB Output is correct
5 Correct 1 ms 872 KB Output is correct
6 Correct 0 ms 908 KB Output is correct
7 Correct 2 ms 876 KB Output is correct
8 Correct 2 ms 988 KB Output is correct
9 Correct 1 ms 748 KB Output is correct
10 Correct 1 ms 980 KB Output is correct
11 Correct 5 ms 920 KB Output is correct
12 Correct 0 ms 868 KB Output is correct
13 Correct 1 ms 748 KB Output is correct
14 Correct 2 ms 876 KB Output is correct
15 Correct 2 ms 876 KB Output is correct
16 Correct 2 ms 972 KB Output is correct
17 Correct 2 ms 876 KB Output is correct
18 Correct 2 ms 748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 3336 KB Output is correct
2 Correct 25 ms 3268 KB Output is correct
3 Correct 25 ms 3268 KB Output is correct
4 Correct 15 ms 2332 KB Output is correct
5 Correct 16 ms 2732 KB Output is correct
6 Correct 15 ms 2280 KB Output is correct
7 Correct 15 ms 2348 KB Output is correct
8 Correct 16 ms 2348 KB Output is correct
9 Correct 15 ms 2348 KB Output is correct
10 Correct 14 ms 2220 KB Output is correct
11 Correct 17 ms 2092 KB Output is correct
12 Correct 14 ms 1820 KB Output is correct
13 Correct 14 ms 2004 KB Output is correct
14 Correct 15 ms 2084 KB Output is correct
15 Correct 15 ms 2380 KB Output is correct
16 Correct 15 ms 2332 KB Output is correct
17 Correct 16 ms 2332 KB Output is correct
18 Correct 15 ms 2092 KB Output is correct
19 Correct 15 ms 2272 KB Output is correct
20 Correct 13 ms 2348 KB Output is correct
21 Correct 13 ms 2220 KB Output is correct
22 Correct 15 ms 2460 KB Output is correct
23 Correct 15 ms 2348 KB Output is correct
24 Correct 15 ms 2460 KB Output is correct
25 Correct 15 ms 2220 KB Output is correct
26 Correct 17 ms 2348 KB Output is correct
27 Correct 15 ms 2220 KB Output is correct
28 Correct 15 ms 2348 KB Output is correct
29 Correct 14 ms 2076 KB Output is correct
30 Correct 15 ms 2084 KB Output is correct
31 Correct 0 ms 1028 KB Output is correct
32 Correct 0 ms 988 KB Output is correct
33 Correct 1 ms 1028 KB Output is correct
34 Correct 2 ms 812 KB Output is correct
35 Correct 0 ms 988 KB Output is correct
36 Correct 0 ms 868 KB Output is correct
37 Correct 0 ms 740 KB Output is correct
38 Correct 1 ms 740 KB Output is correct
39 Correct 0 ms 988 KB Output is correct
40 Correct 0 ms 988 KB Output is correct
41 Correct 0 ms 740 KB Output is correct
42 Correct 0 ms 980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1028 KB Output is correct
2 Correct 1 ms 740 KB Output is correct
3 Correct 0 ms 988 KB Output is correct
4 Correct 3 ms 1028 KB Output is correct
5 Correct 2 ms 932 KB Output is correct
6 Correct 2 ms 1080 KB Output is correct
7 Correct 2 ms 1088 KB Output is correct
8 Correct 2 ms 1080 KB Output is correct
9 Correct 11 ms 2204 KB Output is correct
10 Correct 11 ms 2204 KB Output is correct
11 Correct 11 ms 2460 KB Output is correct
12 Correct 0 ms 988 KB Output is correct
13 Correct 0 ms 980 KB Output is correct
14 Correct 1 ms 988 KB Output is correct
15 Correct 1 ms 744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 1252 KB Wrong Answer [4]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 1160 KB Wrong Answer [4]
2 Halted 0 ms 0 KB -