Submission #839524

# Submission time Handle Problem Language Result Execution time Memory
839524 2023-08-30T08:56:04 Z model_code Choreography (IOI23_choreography) C++17
100 / 100
89 ms 6280 KB
// model_solution/solution.cpp

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

int x0 = 0, x1 = 0, i0 = 0, i1 = 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){
	x0 += + K;
    x1 += + K;
	if(x0 >= n) x0 -= n;
	if(x1 >= n) x1 -= n;
}

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

void swap_places(){
	x0 += x0&1 ? -1 : 1;
    x1 += x1&1 ? 1 : -1;
    if(x1 < 0) x1 += n;
    if(x1 >= n) x1 -= n; 
}

void move_around(){
	s = !s;
	std::swap(x0, i0);
	std::swap(x1, i1);
}

int get_position(int D){
	int i = (D-i0)%2 == 0 ? D - i0 : D - i1;
	if(i < 0) i += n;
	int x = s ? p[i] : inv[i];
	int ans = x&1 ? x + x1 : x + x0; 
	return ans < n ? ans : ans - n;
}
# Verdict Execution time Memory Grader output
1 Correct 89 ms 6216 KB Output is correct
2 Correct 68 ms 6220 KB Output is correct
3 Correct 67 ms 6280 KB Output is correct
4 Correct 65 ms 6220 KB Output is correct
5 Correct 41 ms 4404 KB Output is correct
6 Correct 46 ms 4420 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 3 ms 656 KB Output is correct
5 Correct 1 ms 352 KB Output is correct
6 Correct 4 ms 724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 65 ms 6208 KB Output is correct
2 Correct 59 ms 6220 KB Output is correct
3 Correct 60 ms 6272 KB Output is correct
4 Correct 38 ms 4452 KB Output is correct
5 Correct 39 ms 4404 KB Output is correct
6 Correct 35 ms 4424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 65 ms 6208 KB Output is correct
2 Correct 59 ms 6220 KB Output is correct
3 Correct 60 ms 6272 KB Output is correct
4 Correct 38 ms 4452 KB Output is correct
5 Correct 39 ms 4404 KB Output is correct
6 Correct 35 ms 4424 KB Output is correct
7 Correct 62 ms 6220 KB Output is correct
8 Correct 66 ms 6208 KB Output is correct
9 Correct 60 ms 6212 KB Output is correct
10 Correct 37 ms 4412 KB Output is correct
11 Correct 34 ms 4424 KB Output is correct
12 Correct 34 ms 4396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 89 ms 6216 KB Output is correct
2 Correct 68 ms 6220 KB Output is correct
3 Correct 67 ms 6280 KB Output is correct
4 Correct 65 ms 6220 KB Output is correct
5 Correct 41 ms 4404 KB Output is correct
6 Correct 46 ms 4420 KB Output is correct
7 Correct 65 ms 6208 KB Output is correct
8 Correct 59 ms 6220 KB Output is correct
9 Correct 60 ms 6272 KB Output is correct
10 Correct 38 ms 4452 KB Output is correct
11 Correct 39 ms 4404 KB Output is correct
12 Correct 35 ms 4424 KB Output is correct
13 Correct 70 ms 6200 KB Output is correct
14 Correct 68 ms 6204 KB Output is correct
15 Correct 68 ms 6208 KB Output is correct
16 Correct 51 ms 4404 KB Output is correct
17 Correct 39 ms 4416 KB Output is correct
18 Correct 41 ms 4412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 89 ms 6216 KB Output is correct
2 Correct 68 ms 6220 KB Output is correct
3 Correct 67 ms 6280 KB Output is correct
4 Correct 65 ms 6220 KB Output is correct
5 Correct 41 ms 4404 KB Output is correct
6 Correct 46 ms 4420 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 3 ms 656 KB Output is correct
11 Correct 1 ms 352 KB Output is correct
12 Correct 4 ms 724 KB Output is correct
13 Correct 65 ms 6208 KB Output is correct
14 Correct 59 ms 6220 KB Output is correct
15 Correct 60 ms 6272 KB Output is correct
16 Correct 38 ms 4452 KB Output is correct
17 Correct 39 ms 4404 KB Output is correct
18 Correct 35 ms 4424 KB Output is correct
19 Correct 62 ms 6220 KB Output is correct
20 Correct 66 ms 6208 KB Output is correct
21 Correct 60 ms 6212 KB Output is correct
22 Correct 37 ms 4412 KB Output is correct
23 Correct 34 ms 4424 KB Output is correct
24 Correct 34 ms 4396 KB Output is correct
25 Correct 70 ms 6200 KB Output is correct
26 Correct 68 ms 6204 KB Output is correct
27 Correct 68 ms 6208 KB Output is correct
28 Correct 51 ms 4404 KB Output is correct
29 Correct 39 ms 4416 KB Output is correct
30 Correct 41 ms 4412 KB Output is correct
31 Correct 64 ms 6204 KB Output is correct
32 Correct 65 ms 6220 KB Output is correct
33 Correct 67 ms 6200 KB Output is correct
34 Correct 44 ms 4392 KB Output is correct
35 Correct 40 ms 4352 KB Output is correct
36 Correct 42 ms 4380 KB Output is correct