답안 #1020113

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1020113 2024-07-11T15:07:52 Z shenfe1 자동 인형 (IOI18_doll) C++17
100 / 100
72 ms 15388 KB
#include <bits/stdc++.h>

#include "doll.h"

#define ll long long
#define pb push_back
#define sz(s) (int)s.size()

using namespace std;

const int MAX=2e5+10;

int cnt;
int t[4*MAX];
bool state[4*MAX];

int get(int v,int tl,int tr){
    if(tl==tr)return tl;
    int tm=(tl+tr)/2;
    state[v]^=1;
    if(state[v])return get(2*v,tl,tm);
    else return get(2*v+1,tm+1,tr);
}

int x[MAX],y[MAX];

void build(int v,int tl,int tr,vector<int> &a){
    if(tl==tr){
        if(a[tl]==-1){
            t[v]=MAX;
        }
        else t[v]=a[tl];
        return;
    }
    int tm=(tl+tr)/2;
    build(2*v,tl,tm,a);
    build(2*v+1,tm+1,tr,a);
    if(t[2*v]==MAX&&t[2*v+1]==MAX){
        t[v]=MAX;
        return;
    }
    t[v]=--cnt;
    // cout<<t[v]<<" "<<tl<<" "<<tr<<"\n";
    if(t[2*v]!=MAX){
        x[-t[v]]=t[2*v];
    }
    else{
        x[-t[v]]=MAX;
    }
    if(t[2*v+1]!=MAX){
        y[-t[v]]=t[2*v+1];
    }
    else{
        y[-t[v]]=MAX;
    }
}

void create_circuit(int M, vector<int> A){
    A.pb(0);
    int n=sz(A);
    int cur=1;
    while(cur<sz(A))cur*=2;
    vector<int> f(cur+1,-1);
    vector<int> ord;
    for(int i=0;i<cur;i++){
        int pos=get(1,1,cur);
        if(pos>=cur-n+1){
            ord.pb(pos);
        }
        // cout<<pos<<" ";
    }
    // cout<<'\n';
    for(int i=0;i<n;i++){
        f[ord[i]]=A[i];
    }
    build(1,1,cur,f);
    vector<int> a;
    for(int i=0;i<=M;i++)a.pb(t[1]);
    vector<int> b,c;
    for(int i=1;i<=-cnt;i++){
        if(x[i]==MAX)b.pb(t[1]);
        else b.pb(x[i]);
        if(y[i]==MAX)c.pb(t[1]);
        else c.pb(y[i]);
        // cout<<-i<<" "<<b[i-1]<<"\n"<<-i<<" "<<c[i-1]<<'\n';
    }
    // cout<<-cnt<<"\n";
    // for(int f:b)cout<<f<<" ";
    // cout<<"\n";
    // for(int f:c)cout<<f<<" ";
    // cout<<"\n";
    answer(a,b,c);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 30 ms 6752 KB Output is correct
3 Correct 28 ms 6236 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 6 ms 1748 KB Output is correct
6 Correct 34 ms 9424 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 30 ms 6752 KB Output is correct
3 Correct 28 ms 6236 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 6 ms 1748 KB Output is correct
6 Correct 34 ms 9424 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 50 ms 11292 KB Output is correct
9 Correct 52 ms 11600 KB Output is correct
10 Correct 72 ms 15388 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 30 ms 6752 KB Output is correct
3 Correct 28 ms 6236 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 6 ms 1748 KB Output is correct
6 Correct 34 ms 9424 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 50 ms 11292 KB Output is correct
9 Correct 52 ms 11600 KB Output is correct
10 Correct 72 ms 15388 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 63 ms 14916 KB Output is correct
15 Correct 49 ms 11472 KB Output is correct
16 Correct 61 ms 14912 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 65 ms 15168 KB Output is correct
21 Correct 1 ms 2392 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 46 ms 10348 KB Output is correct
3 Correct 50 ms 10496 KB Output is correct
4 Correct 58 ms 13888 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 46 ms 10348 KB Output is correct
3 Correct 50 ms 10496 KB Output is correct
4 Correct 58 ms 13888 KB Output is correct
5 Correct 62 ms 14656 KB Output is correct
6 Correct 66 ms 14156 KB Output is correct
7 Correct 60 ms 14256 KB Output is correct
8 Correct 63 ms 14400 KB Output is correct
9 Correct 50 ms 10492 KB Output is correct
10 Correct 60 ms 13888 KB Output is correct
11 Correct 58 ms 13892 KB Output is correct
12 Correct 46 ms 10496 KB Output is correct
13 Correct 46 ms 11028 KB Output is correct
14 Correct 46 ms 10780 KB Output is correct
15 Correct 52 ms 10768 KB Output is correct
16 Correct 2 ms 856 KB Output is correct
17 Correct 37 ms 10312 KB Output is correct
18 Correct 45 ms 10240 KB Output is correct
19 Correct 45 ms 10248 KB Output is correct
20 Correct 59 ms 14144 KB Output is correct
21 Correct 66 ms 13892 KB Output is correct
22 Correct 55 ms 13952 KB Output is correct