# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1017908 | nickolasarapidis | Choreography (IOI23_choreography) | C++17 | 0 ms | 0 KiB |
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 "choreography.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
map<int, int> m;
vector<int> A;
void move_right(int K){
int N = A.size();
K = K%N;
vector<int> B(N);
int d = 0;
for(int i = 0; i < K; i++){
B[d] = A[i];
d++;
}
for(int i = K; i < N; i++){
B[d] = A[i];
d++;
}
for(int i = 0; i < N; i++){
A[i] = B[i];
m[A[i]] = i;
}
}
void move_left(int K){
int N = A.size();
K = K%N;
vector<int> B(N);
int d = 0;
for(int i = K; i < N; i++){
B[d] = A[i];
d++;
}
for(int i = 0; i < K; i++){
B[d] = A[i];
d++;
}
for(int i = 0; i < N; i++){
A[i] = B[i];
m[A[i]] = i;
}
}
void swap_places(){
for(int i = 0; i < N/2 - 1; i++){
swap(A[2*i], A[2*i + 1]);
}
for(int i = 0; i < N; i++){
m[A[i]] = i;
}
}
void move_around(){
int N = A.size();
vector<int> B(N);
for(int i = 0; i < N - 1; i++){
B[A[i]] = i;
}
for(int i = 0; i < N; i++){
A[i] = B[i];
}
}
int get_position(int D){
return m[D];
}
void init(int N, vector<int> P){
for(int i = 0; i < N; i++){
m[P[i]] = i;
}
A = P;
}