Submission #853940

#TimeUsernameProblemLanguageResultExecution timeMemory
853940JooDdaeChoreography (IOI23_choreography)C++17
100 / 100
80 ms6760 KiB
#include "choreography.h" #include <bits/stdc++.h> using namespace std; using ll = long long; struct dancer { vector<int> v; ll p[2], f[2]; int o, s; dancer() {} dancer(vector<int> P) : v(P), p{0, 0}, f{0, 1}, o(0), s(0) {} } A, B; void init(int N, vector<int> P) { A = dancer(P); vector<int> R(N); for(int i=0;i<N;i++) R[P[i]] = i; B = dancer(R); return; } void move_right(int K) { for(int i=0;i<2;i++) A.f[i] -= (K + (i != A.s))/2*2; if(K % 2) A.s = !A.s; B.p[0] += K, B.p[1] += K; if(K % 2) B.o = !B.o; return; } void move_left(int K) { for(int i=0;i<2;i++) A.f[i] += (K + (i == A.s))/2*2; if(K % 2) A.s = !A.s; B.p[0] -= K, B.p[1] -= K; if(K % 2) B.o = !B.o; return; } void swap_places() { A.s = !A.s; B.p[B.o]++, B.p[!B.o]--; B.o = !B.o; return; } void move_around() { swap(A, B); return; } int get_position(int D){ int N = A.v.size(); int u = (B.f[(D & 1) ^ B.s]%N + D/2*2 + N) % N; return (B.v[u] + B.p[B.v[u] % 2]%N + N) % 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...