Submission #644888

# Submission time Handle Problem Language Result Execution time Memory
644888 2022-09-25T12:26:31 Z PanTkd Speedrun (RMI21_speedrun) C++14
100 / 100
125 ms 928 KB
#include <bits/stdc++.h>
#include "speedrun.h"

const int MAX_N = 1000;
int father[1+MAX_N], euler[1+MAX_N], lastId;
std::vector<int> graph[1+MAX_N];

void dfs(int node, int dfsfather = 0) {
  father[node] = dfsfather;
  euler[lastId++] = node;

  for (auto it: graph[node])
    if (it != dfsfather) {
      dfs(it, node);
    }
}

void setInteger(int node, int id, int value) {
  int offset = id * 10 + 1;
  for (int b = 0; b < 10; ++b) {
    if ((1 << b) & value)
      setHint(node, offset + b, true);
  }
}

int readInteger(int id) {
  int offset = id * 10 + 1;
  int value = 0;
  for (int b = 0; b < 10; ++b) {
    value = value ^ (getHint(offset + b) << b);
  }
  return value;
}

void assignHints(int subtask, int N, int A[], int B[]) {
  setHintLen(20);
  for (int i = 1; i <= N - 1; ++i) {
    graph[A[i]].push_back(B[i]);
    graph[B[i]].push_back(A[i]);
  }
  dfs(1);
  
  for (int i = 0; i < N; ++i) {
    setInteger(i + 1, 0, father[i + 1]);
    setInteger(euler[i], 1, euler[(i + 1) % N]);
  }
}

void speedrun(int subtask, int N, int start) {
  int node = start;
  do {
    int target = readInteger(1);
    while (!goTo(target)) {
      node = readInteger(0);
      goTo(node);
    }
    node = target;
  } while (node != start);
}

# Verdict Execution time Memory Grader output
1 Correct 110 ms 712 KB Output is correct
2 Correct 75 ms 744 KB Output is correct
3 Correct 100 ms 708 KB Output is correct
4 Correct 96 ms 712 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 98 ms 708 KB Output is correct
2 Correct 96 ms 772 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 92 ms 672 KB Output is correct
2 Correct 106 ms 804 KB Output is correct
3 Correct 119 ms 672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 83 ms 684 KB Output is correct
2 Correct 90 ms 700 KB Output is correct
3 Correct 110 ms 716 KB Output is correct
4 Correct 106 ms 676 KB Output is correct
5 Correct 100 ms 712 KB Output is correct
6 Correct 104 ms 716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 106 ms 928 KB Output is correct
2 Correct 108 ms 724 KB Output is correct
3 Correct 103 ms 856 KB Output is correct
4 Correct 125 ms 684 KB Output is correct
5 Correct 103 ms 704 KB Output is correct
6 Correct 86 ms 792 KB Output is correct
7 Correct 95 ms 672 KB Output is correct