제출 #839544

#제출 시각아이디문제언어결과실행 시간메모리
839544model_codeChoreography (IOI23_choreography)C++17
100 / 100
90 ms6288 KiB
// correct/sol_na_full.cpp #include "choreography.h" #include <vector> #include <iostream> #include <cassert> std::vector<int> p, pos; int n,add[2],addi[2]; bool inv=false; void init(int N, std::vector<int> P) { n=N; p=P; pos.resize(N); for(int i=0;i<N;++i) { pos[P[i]]=i; } } void move_right(int K) { add[0]=(add[0]+K+n)%n; add[1]=(add[1]+K+n)%n; } void move_left(int K) { move_right(n-K); } void swap_places() { int x=add[0]%2==0?1:-1; add[0]=(add[0]+x+n)%n; add[1]=(add[1]-x+n)%n; } void move_around() { inv=!inv; std::swap(add[0], addi[0]); std::swap(add[1], addi[1]); } int get_position(int D){ auto& x=(inv?p:pos); int poz=(D-addi[0])%2==0?D-addi[0]:D-addi[1]; poz+=n;poz%=n; return (x[poz]+(x[poz]%2?add[1]:add[0]))%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...