답안 #120380

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
120380 2019-06-24T09:49:16 Z songc 자동 인형 (IOI18_doll) C++14
100 / 100
206 ms 11712 KB
#include <bits/stdc++.h>
#include "doll.h"
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;

int N, M, B, S;
int ID[808080], num;
int L[202020], R[202020];
bool st[202020];
vector<int> A;

void index(int id, int s, int e){
    if (s == e || e <= B-N) return;
    ID[id] = ++S;
    int mid = (s+e)/2;
    index(id*2, s, mid);
    index(id*2+1, mid+1, e);
}

void f(int id, int s, int e){
    if (e <= B-N){
        L[ID[id/2]] = -1;
        return;
    }
    if (s == e) return;
    int mid = (s+e)/2;
    f(id*2, s, mid);
    f(id*2+1, mid+1, e);
    if (id & 1) R[ID[id/2]] = -ID[id];
    else L[ID[id/2]] = -ID[id];
}

void create_circuit(int m, std::vector<int> a){
    a.push_back(0);
    N = a.size(), M = m, A = a;
    for (B=1; B<N; B<<=1);
    index(1, 1, B);
    f(1, 1, B);

    for (int i=0; i<N; i++){
        int u=1;
        while (1){
            if (!st[u]){
                if (L[u] == 0){
                    L[u] = A[i];
                    st[u] = !st[u];
                    break;
                }
                else st[u] = !st[u], u=-L[u];
            }
            else{
                if (R[u] == 0){
                    R[u] = A[i];
                    st[u] = !st[u];
                    break;
                }
                else st[u] = !st[u], u=-R[u];
            }
        }
    }

    vector<int> C(M+1, -1);
    vector<int> X, Y;
    for (int i=1; i<=S; i++){
        X.push_back(L[i]);
        Y.push_back(R[i]);
    }
    answer(C, X, Y);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 52 ms 4936 KB Output is correct
3 Correct 53 ms 4976 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 12 ms 1484 KB Output is correct
6 Correct 69 ms 7224 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 52 ms 4936 KB Output is correct
3 Correct 53 ms 4976 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 12 ms 1484 KB Output is correct
6 Correct 69 ms 7224 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 114 ms 7684 KB Output is correct
9 Correct 112 ms 8260 KB Output is correct
10 Correct 156 ms 11712 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 52 ms 4936 KB Output is correct
3 Correct 53 ms 4976 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 12 ms 1484 KB Output is correct
6 Correct 69 ms 7224 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 114 ms 7684 KB Output is correct
9 Correct 112 ms 8260 KB Output is correct
10 Correct 156 ms 11712 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 157 ms 11124 KB Output is correct
15 Correct 89 ms 7196 KB Output is correct
16 Correct 135 ms 10868 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 146 ms 11388 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 2 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 204 KB Output is correct
2 Correct 84 ms 6544 KB Output is correct
3 Correct 84 ms 6548 KB Output is correct
4 Correct 134 ms 9868 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 204 KB Output is correct
2 Correct 84 ms 6544 KB Output is correct
3 Correct 84 ms 6548 KB Output is correct
4 Correct 134 ms 9868 KB Output is correct
5 Correct 206 ms 10732 KB Output is correct
6 Correct 166 ms 10516 KB Output is correct
7 Correct 133 ms 10576 KB Output is correct
8 Correct 138 ms 10236 KB Output is correct
9 Correct 98 ms 6540 KB Output is correct
10 Correct 121 ms 10084 KB Output is correct
11 Correct 133 ms 9900 KB Output is correct
12 Correct 79 ms 6544 KB Output is correct
13 Correct 85 ms 6996 KB Output is correct
14 Correct 78 ms 7008 KB Output is correct
15 Correct 81 ms 7080 KB Output is correct
16 Correct 4 ms 588 KB Output is correct
17 Correct 85 ms 7772 KB Output is correct
18 Correct 98 ms 6548 KB Output is correct
19 Correct 76 ms 6628 KB Output is correct
20 Correct 133 ms 10068 KB Output is correct
21 Correct 132 ms 9844 KB Output is correct
22 Correct 146 ms 9848 KB Output is correct