Submission #946790

#TimeUsernameProblemLanguageResultExecution timeMemory
946790pravcoderChoreography (IOI23_choreography)C++17
0 / 100
1070 ms7372 KiB
#include "choreography.h" #include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> #include <string> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vi> v2i; typedef pair<int, int> pi; typedef vector<pi> vp; #define pb push_back #define mp make_pair #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; vi p; int n; vp moves; vi counts(4, 0); vi pos; void init(int N, vi P) { p = P; n = N; pos.resize(N); int i = 0; for (auto d : P) { pos[d] = i++; } } void move_right(int K) { moves.pb({ 1, K }); counts[0]++; } void move_left(int K) { moves.pb({ 2, K }); counts[1]++; } void swap_places() { moves.pb({ 3, 0 }); counts[2]++; } void move_around() { moves.pb({ 4, 0 }); counts[3]++; } int get_position(int D){ int res = pos[D]; for (auto move : moves) { if (move.first == 1) res += move.second; else res -= move.second; res = (res % n + n) % n; } return res; }
#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...