답안 #847686

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
847686 2023-09-10T06:56:58 Z heavylightdecomp Choreography (IOI23_choreography) C++17
100 / 100
78 ms 6792 KB
#include<bits/stdc++.h>
using namespace std;
const long long maxn = 1e5+5;
long long N;
struct row {
    vector<int> ar;
    long long ch, ech;
    friend void swap(row &a, row &b) {
        a.ar.swap(b.ar);
        swap(a.ch, b.ch);
        swap(a.ech, b.ech);
    }
};
row x,y;
void init(int n, vector<int> p) {
    N = n;
    x.ar = vector<int>(N);
    y.ar = vector<int>(N);
    for(int i = 0; i < N; i++) {
        x.ar[i] = p[i]; // x to y
        y.ar[p[i]] = i; // y to x
    }
}
int fix(long long c) {
    c += maxn * N;
    return c % N;

}
void move_right(int K) {
    x.ch += K;
}
void move_left(int K) {
    x.ch -= K;
}
void swap_places() {
    x.ech += ((x.ech + x.ch) % 2) ? -1 : 1;
}
void move_around() {
    swap(x,y);
}

int get_position(int D) {
    /*
    Careful! 
    x[i] represents p[i+s mod N]
    x[i-s mod N] represents p[i], the intended value
    same for y
    */
    long long ce = fix(D - y.ch - y.ech);
    long long co = fix(D - y.ch + y.ech);
    long long yp = -1;
    if(ce % 2 == 0) {
        yp = ce;
    } else {
        yp = co;
    }
    return fix(y.ar[yp] + x.ch + ((y.ar[yp] % 2) ? -x.ech : x.ech));  
}
# 결과 실행 시간 메모리 Grader output
1 Correct 66 ms 6340 KB Output is correct
2 Correct 78 ms 6348 KB Output is correct
3 Correct 65 ms 6236 KB Output is correct
4 Correct 73 ms 6340 KB Output is correct
5 Correct 45 ms 4532 KB Output is correct
6 Correct 43 ms 4564 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 3 ms 856 KB Output is correct
5 Correct 2 ms 344 KB Output is correct
6 Correct 3 ms 856 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 58 ms 6340 KB Output is correct
2 Correct 60 ms 6340 KB Output is correct
3 Correct 64 ms 6792 KB Output is correct
4 Correct 36 ms 4552 KB Output is correct
5 Correct 45 ms 4512 KB Output is correct
6 Correct 35 ms 4552 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 58 ms 6340 KB Output is correct
2 Correct 60 ms 6340 KB Output is correct
3 Correct 64 ms 6792 KB Output is correct
4 Correct 36 ms 4552 KB Output is correct
5 Correct 45 ms 4512 KB Output is correct
6 Correct 35 ms 4552 KB Output is correct
7 Correct 60 ms 6340 KB Output is correct
8 Correct 58 ms 6360 KB Output is correct
9 Correct 59 ms 6340 KB Output is correct
10 Correct 36 ms 4560 KB Output is correct
11 Correct 41 ms 4392 KB Output is correct
12 Correct 43 ms 4556 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 66 ms 6340 KB Output is correct
2 Correct 78 ms 6348 KB Output is correct
3 Correct 65 ms 6236 KB Output is correct
4 Correct 73 ms 6340 KB Output is correct
5 Correct 45 ms 4532 KB Output is correct
6 Correct 43 ms 4564 KB Output is correct
7 Correct 58 ms 6340 KB Output is correct
8 Correct 60 ms 6340 KB Output is correct
9 Correct 64 ms 6792 KB Output is correct
10 Correct 36 ms 4552 KB Output is correct
11 Correct 45 ms 4512 KB Output is correct
12 Correct 35 ms 4552 KB Output is correct
13 Correct 67 ms 6288 KB Output is correct
14 Correct 65 ms 6352 KB Output is correct
15 Correct 68 ms 6352 KB Output is correct
16 Correct 42 ms 4564 KB Output is correct
17 Correct 45 ms 4552 KB Output is correct
18 Correct 49 ms 4528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 66 ms 6340 KB Output is correct
2 Correct 78 ms 6348 KB Output is correct
3 Correct 65 ms 6236 KB Output is correct
4 Correct 73 ms 6340 KB Output is correct
5 Correct 45 ms 4532 KB Output is correct
6 Correct 43 ms 4564 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 348 KB Output is correct
10 Correct 3 ms 856 KB Output is correct
11 Correct 2 ms 344 KB Output is correct
12 Correct 3 ms 856 KB Output is correct
13 Correct 58 ms 6340 KB Output is correct
14 Correct 60 ms 6340 KB Output is correct
15 Correct 64 ms 6792 KB Output is correct
16 Correct 36 ms 4552 KB Output is correct
17 Correct 45 ms 4512 KB Output is correct
18 Correct 35 ms 4552 KB Output is correct
19 Correct 60 ms 6340 KB Output is correct
20 Correct 58 ms 6360 KB Output is correct
21 Correct 59 ms 6340 KB Output is correct
22 Correct 36 ms 4560 KB Output is correct
23 Correct 41 ms 4392 KB Output is correct
24 Correct 43 ms 4556 KB Output is correct
25 Correct 67 ms 6288 KB Output is correct
26 Correct 65 ms 6352 KB Output is correct
27 Correct 68 ms 6352 KB Output is correct
28 Correct 42 ms 4564 KB Output is correct
29 Correct 45 ms 4552 KB Output is correct
30 Correct 49 ms 4528 KB Output is correct
31 Correct 67 ms 6344 KB Output is correct
32 Correct 64 ms 6340 KB Output is correct
33 Correct 63 ms 6364 KB Output is correct
34 Correct 39 ms 4552 KB Output is correct
35 Correct 40 ms 4552 KB Output is correct
36 Correct 40 ms 4532 KB Output is correct