Submission #839542

#TimeUsernameProblemLanguageResultExecution timeMemory
839542model_codeChoreography (IOI23_choreography)C++17
12 / 100
1084 ms4244 KiB
// correct/solution-subtask2.cpp

#include "choreography.h"
#include <vector>
#include <iostream>

int n;
std::vector<int> p;

void init(int N, std::vector<int> P){
    n = N;
    p = P;
}

void move_right(int K){
    std::vector<int> p2(n);
    for(int i = 0; i < n; i++){
        p2[i] = p[((i - K) % n + n) % n];
    }
    std::swap(p, p2);
}

void move_left(int K){
    move_right(-K);
}

void swap_places(){
    for(int i = 0; i < n; i += 2){
        std::swap(p[i], p[i+1]);
    }
}

void move_around(){
    std::vector<int> inv(n);
    for(int i = 0; i < n; i++) {
        inv[p[i]] = i;
    }
    std::swap(inv, p);
}

int get_position(int D){
    int j = 0;
    while(p[j] != D) ++j;
    return j;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...