Submission #839549

#TimeUsernameProblemLanguageResultExecution timeMemory
839549model_codeChoreography (IOI23_choreography)C++17
45 / 100
82 ms6272 KiB
// correct/solution-subtask5.cpp

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

int x = 0, j = 0, n;
bool s = false;
std::vector<int> p, inv;

void init(int N, std::vector<int> P){
	n = N;
	p = P;
	inv.resize(N);
	for(int i = 0; i < N; i++){
		inv[P[i]] = i;
	}
}

void move_right(int K){
    x += K;
	if(x >= n) x -= n;
}

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

void swap_places() {}

void move_around(){
	s = !s;
	std::swap(x, j);
}

int get_position(int D){
	int i = D - j;
	if(i < 0) i += n;
	int ans = s ? p[i] + x : inv[i] + x; 
	return ans < n ? ans : ans - n;
}
#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...