Submission #853940

# Submission time Handle Problem Language Result Execution time Memory
853940 2023-09-25T14:58:08 Z JooDdae Choreography (IOI23_choreography) C++17
100 / 100
80 ms 6760 KB
#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 time Memory Grader output
1 Correct 72 ms 6540 KB Output is correct
2 Correct 69 ms 6484 KB Output is correct
3 Correct 68 ms 6464 KB Output is correct
4 Correct 68 ms 6520 KB Output is correct
5 Correct 45 ms 4832 KB Output is correct
6 Correct 45 ms 4924 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 3 ms 1112 KB Output is correct
5 Correct 1 ms 600 KB Output is correct
6 Correct 3 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 62 ms 6464 KB Output is correct
2 Correct 63 ms 6760 KB Output is correct
3 Correct 61 ms 6464 KB Output is correct
4 Correct 37 ms 4924 KB Output is correct
5 Correct 39 ms 4924 KB Output is correct
6 Correct 38 ms 4928 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 62 ms 6464 KB Output is correct
2 Correct 63 ms 6760 KB Output is correct
3 Correct 61 ms 6464 KB Output is correct
4 Correct 37 ms 4924 KB Output is correct
5 Correct 39 ms 4924 KB Output is correct
6 Correct 38 ms 4928 KB Output is correct
7 Correct 80 ms 6460 KB Output is correct
8 Correct 76 ms 6464 KB Output is correct
9 Correct 61 ms 6460 KB Output is correct
10 Correct 37 ms 4936 KB Output is correct
11 Correct 37 ms 4672 KB Output is correct
12 Correct 38 ms 4672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 72 ms 6540 KB Output is correct
2 Correct 69 ms 6484 KB Output is correct
3 Correct 68 ms 6464 KB Output is correct
4 Correct 68 ms 6520 KB Output is correct
5 Correct 45 ms 4832 KB Output is correct
6 Correct 45 ms 4924 KB Output is correct
7 Correct 62 ms 6464 KB Output is correct
8 Correct 63 ms 6760 KB Output is correct
9 Correct 61 ms 6464 KB Output is correct
10 Correct 37 ms 4924 KB Output is correct
11 Correct 39 ms 4924 KB Output is correct
12 Correct 38 ms 4928 KB Output is correct
13 Correct 65 ms 6460 KB Output is correct
14 Correct 71 ms 6460 KB Output is correct
15 Correct 65 ms 6460 KB Output is correct
16 Correct 47 ms 4924 KB Output is correct
17 Correct 43 ms 4872 KB Output is correct
18 Correct 43 ms 4924 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 72 ms 6540 KB Output is correct
2 Correct 69 ms 6484 KB Output is correct
3 Correct 68 ms 6464 KB Output is correct
4 Correct 68 ms 6520 KB Output is correct
5 Correct 45 ms 4832 KB Output is correct
6 Correct 45 ms 4924 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 3 ms 1112 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 3 ms 1116 KB Output is correct
13 Correct 62 ms 6464 KB Output is correct
14 Correct 63 ms 6760 KB Output is correct
15 Correct 61 ms 6464 KB Output is correct
16 Correct 37 ms 4924 KB Output is correct
17 Correct 39 ms 4924 KB Output is correct
18 Correct 38 ms 4928 KB Output is correct
19 Correct 80 ms 6460 KB Output is correct
20 Correct 76 ms 6464 KB Output is correct
21 Correct 61 ms 6460 KB Output is correct
22 Correct 37 ms 4936 KB Output is correct
23 Correct 37 ms 4672 KB Output is correct
24 Correct 38 ms 4672 KB Output is correct
25 Correct 65 ms 6460 KB Output is correct
26 Correct 71 ms 6460 KB Output is correct
27 Correct 65 ms 6460 KB Output is correct
28 Correct 47 ms 4924 KB Output is correct
29 Correct 43 ms 4872 KB Output is correct
30 Correct 43 ms 4924 KB Output is correct
31 Correct 64 ms 6460 KB Output is correct
32 Correct 64 ms 6492 KB Output is correct
33 Correct 64 ms 6460 KB Output is correct
34 Correct 41 ms 4672 KB Output is correct
35 Correct 41 ms 4672 KB Output is correct
36 Correct 44 ms 4932 KB Output is correct