답안 #525096

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
525096 2022-02-10T17:07:39 Z Redhood 자동 인형 (IOI18_doll) C++14
43 / 100
168 ms 27864 KB
#include<bits/stdc++.h>
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
#define pb push_back

#include "doll.h"
typedef long long ll;
typedef long double ld;

using namespace std;
const int N = (int)5e5 + 10;

int lst = 0;
vector<int>trans[N];
int m;
int x[N],y[N];
int was = -1;
int build(vector<int>k, int ROOT){
    if(sz(k) == 1){
        if(k[0] == -1){
            if(was == -1){
                was = lst;
                x[lst]=lst;
                y[lst]=ROOT;
                lst++;
            }
            return was;
        }
        return k[0];
    }
//    assert(sz(k) != 0);
    vector<int>st[2];
    if(sz(k) % 2 != 0)
        k.insert(k.begin(), -1);
    for(int i = 0; i < sz(k); ++i)
        st[i&1].pb(k[i]);

//    if(sz(st[0])>sz(st[1])){
//        st[1].insert(st[1].begin(),-1);
//    }
    int v = lst++;
    if(ROOT==-1){
        ROOT = v;
    }

    int A=build(st[0],ROOT),B=build(st[1],ROOT);
    x[v]=A;
    y[v]=B;
    return v;
}
int code(int f){
    if(f <= m)
        return f;
    return -(f-m);
}
bool good(int f){
    int pw=1;
    int F = f;
    while(f){
        f>>=1;
        pw<<=1;
    }
    pw>>=1;
    if(pw==F)
        return true;
    return false;
}
void create_circuit(int M, std::vector<int> A){
    for(int i=0;i<=M;++i)
        trans[i].clear();
    lst=0;
    m = M;
    A.push_back(0);


    A.insert(A.begin(), 0);
    for(int i = 0; i < sz(A) - 1; ++i){
        trans[A[i]].push_back(A[i + 1]);
    }
    lst = M + 1;
    vector < int > C(M + 1);

    for(int i = 0; i <= M; ++i){
        if(sz(trans[i]) == 0)
            continue;
        bool bad=0;
        for(int j : trans[i]){
            if(j != trans[i][0])
                bad=1;
        }
        if(!bad){
            C[i] = trans[i][0];
            continue;
        }
//        reverse(all(trans[i]));
//        while(!good(sz(trans[i]))){
//            trans[i].pb(-1);
//        }
//        reverse(all(trans[i]));
//        cout << " SZ " << sz(trans[i]) << endl;

        was = -1;
        if(sz(trans[i]) == 1){
            C[i] = trans[i][0];
        }else{
            C[i] = code(build(trans[i], -1));
        }
    }
    vector<int>X(lst-1-M),Y(lst-1-M);
    for(int f=0;f<sz(X);++f){
        X[f]=code(x[M+1+f]);
        Y[f]=code(y[M+1+f]);
    }
//    cout << "WTF " << sz(X) << ' ' << N << endl;
        assert(sz(X) <= 2 * sz(A));
//    cout << "LOL \n";
//    for(int i = 0; i <= M; ++i)
//        cout << C[i] << '\n';
//    for(int f = 0; f < sz(X); ++f){
//        cout << X[f] << ' ' << Y[f] << endl;
//    }
//    cout << endl;
    answer(C,X,Y);
}
/*
4 6
1 2 1 3 1 4
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 11980 KB Output is correct
2 Correct 28 ms 15788 KB Output is correct
3 Correct 23 ms 15460 KB Output is correct
4 Correct 6 ms 11980 KB Output is correct
5 Correct 15 ms 13132 KB Output is correct
6 Correct 33 ms 17288 KB Output is correct
7 Correct 6 ms 11980 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 11980 KB Output is correct
2 Correct 28 ms 15788 KB Output is correct
3 Correct 23 ms 15460 KB Output is correct
4 Correct 6 ms 11980 KB Output is correct
5 Correct 15 ms 13132 KB Output is correct
6 Correct 33 ms 17288 KB Output is correct
7 Correct 6 ms 11980 KB Output is correct
8 Correct 53 ms 18612 KB Output is correct
9 Correct 57 ms 18836 KB Output is correct
10 Correct 82 ms 22080 KB Output is correct
11 Correct 6 ms 11980 KB Output is correct
12 Correct 6 ms 12060 KB Output is correct
13 Correct 6 ms 11980 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 11980 KB Output is correct
2 Correct 28 ms 15788 KB Output is correct
3 Correct 23 ms 15460 KB Output is correct
4 Correct 6 ms 11980 KB Output is correct
5 Correct 15 ms 13132 KB Output is correct
6 Correct 33 ms 17288 KB Output is correct
7 Correct 6 ms 11980 KB Output is correct
8 Correct 53 ms 18612 KB Output is correct
9 Correct 57 ms 18836 KB Output is correct
10 Correct 82 ms 22080 KB Output is correct
11 Correct 6 ms 11980 KB Output is correct
12 Correct 6 ms 12060 KB Output is correct
13 Correct 6 ms 11980 KB Output is correct
14 Incorrect 114 ms 24856 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 11980 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 6 ms 11980 KB Output is partially correct
2 Correct 68 ms 18956 KB Output is correct
3 Partially correct 117 ms 24508 KB Output is partially correct
4 Partially correct 129 ms 25140 KB Output is partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 6 ms 11980 KB Output is partially correct
2 Correct 68 ms 18956 KB Output is correct
3 Partially correct 117 ms 24508 KB Output is partially correct
4 Partially correct 129 ms 25140 KB Output is partially correct
5 Partially correct 138 ms 26312 KB Output is partially correct
6 Partially correct 150 ms 26964 KB Output is partially correct
7 Partially correct 151 ms 26744 KB Output is partially correct
8 Partially correct 153 ms 27460 KB Output is partially correct
9 Partially correct 112 ms 22708 KB Output is partially correct
10 Partially correct 167 ms 27584 KB Output is partially correct
11 Partially correct 168 ms 27864 KB Output is partially correct
12 Partially correct 109 ms 22464 KB Output is partially correct
13 Partially correct 102 ms 21900 KB Output is partially correct
14 Partially correct 97 ms 21580 KB Output is partially correct
15 Partially correct 93 ms 21392 KB Output is partially correct
16 Partially correct 9 ms 12236 KB Output is partially correct
17 Partially correct 93 ms 20244 KB Output is partially correct
18 Partially correct 88 ms 20288 KB Output is partially correct
19 Partially correct 96 ms 20928 KB Output is partially correct
20 Partially correct 120 ms 23444 KB Output is partially correct
21 Partially correct 144 ms 25780 KB Output is partially correct
22 Partially correct 114 ms 22772 KB Output is partially correct