This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <vector>
  std::vector<int> POSITIONS;
  std::vector<int> DANCERS;
  int NUM_OF_POSITIONS;
  int OFFSET;
  /**
   * @brief
   *
   */
  void update_dancers_array() {
    for (int i = 0; i < NUM_OF_POSITIONS; i++) {
      DANCERS[POSITIONS[i]] = (OFFSET + i) % NUM_OF_POSITIONS;
    }
    OFFSET = 0;
  }
  /**
   * @brief
   *
   */
  void update_positions_array() {
    for (int i = 0; i < NUM_OF_POSITIONS; i++) {
      POSITIONS[(DANCERS[i] + OFFSET) % NUM_OF_POSITIONS] = i;
    }
    OFFSET = 0;
  }
  /**
   * @brief This procedure is called once at the beginning of the choreography.
   *
   * @param N The number of dancers.
   * @param P Array of length N describing the initial order of the dancers.
   */
  void init(int N, std::vector<int> P) {
    NUM_OF_POSITIONS = N;
    OFFSET = 0;
    for (int i = 0; i < N; i++) {
      POSITIONS.push_back(P[i]);
      DANCERS.push_back(i);
    }
    update_dancers_array();
    return;
  }
  void move_right(int K) {
    OFFSET = (OFFSET + K) % NUM_OF_POSITIONS;
    return;
  }
  void move_left(int K) {
    OFFSET = (OFFSET - K + NUM_OF_POSITIONS) % NUM_OF_POSITIONS;
    return;
  }
  /**
   * @brief This procedure adds a move of type 3 to the sequence of moves.
   *
   */
  void swap_places() {
    update_positions_array();
    for (int i = 0; i < NUM_OF_POSITIONS / 2; i++) {
      int temp = POSITIONS[2 * i];
      POSITIONS[2 * i] = POSITIONS[2 * i + 1];
      POSITIONS[2 * i + 1] = temp;
    }
    update_dancers_array();
    return;
  }
  /**
   * @brief This procedure adds a move of type 4 to the sequence of moves.
   *
   */
  void move_around() {
    update_positions_array();
    std::vector<int> temp = POSITIONS;
    for (int i = 0; i < NUM_OF_POSITIONS; i++) {
      POSITIONS[temp[i]] = i;
    }
    update_dancers_array();
    return;
  }
  /**
   * @brief This procedure should return the position of dancer D after performing every move added
   * to the sequence of moves before this call.
   *
   * @param D an integer representing a dancer.
   * @return int
   */
  int get_position(int D) { 
    return (DANCERS[D] + OFFSET) % NUM_OF_POSITIONS; 
  }
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |