Submission #1075129

# Submission time Handle Problem Language Result Execution time Memory
1075129 2024-08-25T18:49:56 Z TB_ Mechanical Doll (IOI18_doll) C++17
6 / 100
50 ms 17160 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define fo(i, n) for(ll i = 0; i<(n); i++)
#define pb push_back
#define F first
#define S second
#define deb(x) cout << #x << " = " << (x) << endl 
#define deb2(x, y) cout << #x << " = " << (x)  << ", " << #y << " = " << (y) << endl 
typedef vector<ll> vl;
typedef vector<vl> vvl;

// void answer(std::vector<int> C, std::vector<int> X, std::vector<int> Y){

// }
void answer(std::vector<int> C, std::vector<int> X, std::vector<int> Y);
void create_circuit(int M, std::vector<int> A){
    vvl adj(M+1);
    ll n = A.size();
    adj[0].pb(A[0]);
    fo(i, n){
        if(i<n-1) adj[A[i]].pb(A[i+1]);
        else adj[A[i]].pb(0);
    }
    ll cou = 0;
    vector<int> c, x, y;
    fo(i, M+1){
        cou = x.size();
        ll co = 0;
        if(adj[i].size() == 0){
            c.pb(i);
            continue;
        }
        else if(adj[i].size() == 1){
            c.pb(adj[i][0]);
            continue;
        }
        c.pb(-cou-1);
        ll am = adj[i].size();
        ll ext = 1;
        while(ext<am) ext*=2ll;
        ll am2 = ext-am;
        vl order(ext*2);
        vl state(ext, 0);
        // deb(ext);
        fo(j, ext){
            ll current = 1;
            while(current<ext){
                ll sta = state[current]; 
                state[current] = !state[current];
                current*=2;
                if(sta)current++;
            }
            // deb(am2);
            // deb2(ext-current-1, am2);
            if(current<am2+ext) order[current] = (-cou-1);
            else order[current] = (adj[i][co++]);
            // deb2(current, order[current]);
        }
        co= 0;
        fo(i, ext){
            if(!i) continue;
            if(i*2<ext){
                if(order[(-cou-i*2)*2] == order[(-cou-i*2)*2+1]) x.pb(order[(-cou-i*2)*2]);
                else x.pb(-cou-i*2);
                if(order[(-cou-i*2-1)*2] == order[(-cou-i*2-1)*2+1]) y.pb(order[(-cou-i*2-1)*2]);
                else y.pb(-cou-i*2-1);
            }else{
                x.pb(order[i*2]);
                y.pb(order[i*2+1]);

            }

        }
    }
    // fo(i, c.size()){
    //     deb(c[i]);
    // }
    // fo(i, x.size()){
    //     deb2(x[i], y[i]);
    // }
    answer(c, x, y);
}



// int main(){

//     // vector<int> st = {1, 2, 1, 3};
//     vector<int> st = {1, 2, 1, 2, 1};
//     create_circuit(3, st);

//     return 0;
// }


# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 17 ms 6960 KB Output is correct
3 Correct 15 ms 5600 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 7 ms 4052 KB Output is correct
6 Correct 23 ms 8500 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 17 ms 6960 KB Output is correct
3 Correct 15 ms 5600 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 7 ms 4052 KB Output is correct
6 Correct 23 ms 8500 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 33 ms 8272 KB Output is correct
9 Correct 34 ms 9700 KB Output is correct
10 Correct 50 ms 12616 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 17 ms 6960 KB Output is correct
3 Correct 15 ms 5600 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 7 ms 4052 KB Output is correct
6 Correct 23 ms 8500 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 33 ms 8272 KB Output is correct
9 Correct 34 ms 9700 KB Output is correct
10 Correct 50 ms 12616 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Runtime error 35 ms 17160 KB Execution killed with signal 11
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB wrong motion
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB wrong motion
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB wrong motion
2 Halted 0 ms 0 KB -