Submission #923226

#TimeUsernameProblemLanguageResultExecution timeMemory
923226AdamGSChoreography (IOI23_choreography)C++17
59 / 100
82 ms6596 KiB
#include "choreography.h" #include<bits/stdc++.h> using namespace std; #define rep(a, b) for(int a = 0; a < (b); ++a) #define st first #define nd second #define pb push_back #define all(a) a.begin(), a.end() const int LIM=1e5+7; int P[LIM], Q[LIM], n, a, b, inv; vector<int>A, B; void init(int N, vector<int>_P) { n=N; rep(i, n) P[i]=_P[i]; rep(i, n) Q[P[i]]=i; } void move_right(int k) { if(!inv) a=(a+k)%n; else b=(b+k)%n; } void move_left(int k) { move_right((n-k)%n); } void swap_places() { if(!inv) { if(A.size() && A.back()==a%2) A.pop_back(); else A.pb(a%2); } else { if(B.size() && B.back()==b%2) B.pop_back(); else B.pb(b%2); } } void move_around() { inv^=1; } int get_position(int d) { if(!inv) { int z=d, p=B.size()%n; z=(z-b+n)%n; if(B.size() && z%2==B[0]) z=(z+p)%n; else z=(z-p+n)%n; int x=Q[z]; p=A.size()%n; if(A.size() && x%2==A[0]) x=(x+p)%n; else x=(x-p+n)%n; return (x+a)%n; } int z=d, p=A.size()%n; z=(z-a+n)%n; if(A.size() && z%2==A[0]) z=(z+p)%n; else z=(z-p+n)%n; int x=P[z]; p=B.size()%n; if(B.size() && x%2==B[0]) x=(x+p)%n; else x=(x-p+n)%n; return (x+b)%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...