답안 #923227

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
923227 2024-02-07T01:22:27 Z AdamGS Choreography (IOI23_choreography) C++17
100 / 100
70 ms 9032 KB
#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.back()) 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.back()) 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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 70 ms 6608 KB Output is correct
2 Correct 66 ms 6344 KB Output is correct
3 Correct 66 ms 6416 KB Output is correct
4 Correct 66 ms 6372 KB Output is correct
5 Correct 53 ms 4644 KB Output is correct
6 Correct 48 ms 4568 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 3 ms 860 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 3 ms 860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 67 ms 6332 KB Output is correct
2 Correct 59 ms 6376 KB Output is correct
3 Correct 59 ms 6356 KB Output is correct
4 Correct 38 ms 4556 KB Output is correct
5 Correct 38 ms 4564 KB Output is correct
6 Correct 35 ms 4556 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 67 ms 6332 KB Output is correct
2 Correct 59 ms 6376 KB Output is correct
3 Correct 59 ms 6356 KB Output is correct
4 Correct 38 ms 4556 KB Output is correct
5 Correct 38 ms 4564 KB Output is correct
6 Correct 35 ms 4556 KB Output is correct
7 Correct 61 ms 6348 KB Output is correct
8 Correct 61 ms 6340 KB Output is correct
9 Correct 63 ms 6364 KB Output is correct
10 Correct 37 ms 4552 KB Output is correct
11 Correct 36 ms 4552 KB Output is correct
12 Correct 37 ms 4552 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 70 ms 6608 KB Output is correct
2 Correct 66 ms 6344 KB Output is correct
3 Correct 66 ms 6416 KB Output is correct
4 Correct 66 ms 6372 KB Output is correct
5 Correct 53 ms 4644 KB Output is correct
6 Correct 48 ms 4568 KB Output is correct
7 Correct 67 ms 6332 KB Output is correct
8 Correct 59 ms 6376 KB Output is correct
9 Correct 59 ms 6356 KB Output is correct
10 Correct 38 ms 4556 KB Output is correct
11 Correct 38 ms 4564 KB Output is correct
12 Correct 35 ms 4556 KB Output is correct
13 Correct 64 ms 6384 KB Output is correct
14 Correct 65 ms 6336 KB Output is correct
15 Correct 65 ms 6332 KB Output is correct
16 Correct 42 ms 4556 KB Output is correct
17 Correct 41 ms 4552 KB Output is correct
18 Correct 42 ms 4556 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 70 ms 6608 KB Output is correct
2 Correct 66 ms 6344 KB Output is correct
3 Correct 66 ms 6416 KB Output is correct
4 Correct 66 ms 6372 KB Output is correct
5 Correct 53 ms 4644 KB Output is correct
6 Correct 48 ms 4568 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 3 ms 860 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 3 ms 860 KB Output is correct
13 Correct 67 ms 6332 KB Output is correct
14 Correct 59 ms 6376 KB Output is correct
15 Correct 59 ms 6356 KB Output is correct
16 Correct 38 ms 4556 KB Output is correct
17 Correct 38 ms 4564 KB Output is correct
18 Correct 35 ms 4556 KB Output is correct
19 Correct 61 ms 6348 KB Output is correct
20 Correct 61 ms 6340 KB Output is correct
21 Correct 63 ms 6364 KB Output is correct
22 Correct 37 ms 4552 KB Output is correct
23 Correct 36 ms 4552 KB Output is correct
24 Correct 37 ms 4552 KB Output is correct
25 Correct 64 ms 6384 KB Output is correct
26 Correct 65 ms 6336 KB Output is correct
27 Correct 65 ms 6332 KB Output is correct
28 Correct 42 ms 4556 KB Output is correct
29 Correct 41 ms 4552 KB Output is correct
30 Correct 42 ms 4556 KB Output is correct
31 Correct 68 ms 8908 KB Output is correct
32 Correct 67 ms 9032 KB Output is correct
33 Correct 66 ms 8900 KB Output is correct
34 Correct 48 ms 6344 KB Output is correct
35 Correct 41 ms 6344 KB Output is correct
36 Correct 42 ms 6344 KB Output is correct