Submission #218297

# Submission time Handle Problem Language Result Execution time Memory
218297 2020-04-01T22:38:03 Z edsa Mechanical Doll (IOI18_doll) C++14
0 / 100
5 ms 5068 KB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vii = vector<ii>;
const ll MOD = 998244353;
const int INF = 1e9+9;
const int MAXN = 200005;

#include "doll.h"

int sm[2*MAXN], add[2*MAXN];
vi gr[MAXN];
vi C, X, Y;

void create_circuit(int M, vector<int> A) {
    for (int i = 1; i < (int) A.size(); ++i) {
        gr[A[i-1]].push_back(A[i]);
    }
    gr[A.back()].push_back(0);
    C.resize(M+1);
    C[0] = 1;

    for (int i = 1; i <= M; ++i) {
        if (gr[i].empty()) {
            C[i] = 0;
            continue;
        }
        if (gr[i].size() == 1) {
            C[i] = gr[i][0];
            continue;
        }

        int logg = 0;
        while ((1<<logg) < (int)gr[i].size())
            logg++;
        // cerr << i << ": " << logg << endl;

        int fSw = X.size(); // first new switch
        X.resize((int) X.size()+(1<<logg)-1);
        Y.resize((int) Y.size()+(1<<logg)-1);

        C[i] = -fSw-1;
        gr[i].insert(gr[i].begin(), (1<<logg)-(int)gr[i].size(), -fSw-1);

        sm[1] = 0;
        add[1] = 1;
        int n = 1<<(logg-1);
        --fSw;
        for (int j = 1; j < n; ++j) {
            X[fSw+j] = -fSw-(j<<1);
            Y[fSw+j] = -fSw-(j<<1|1);
            sm[j<<1] = sm[j];
            sm[j<<1|1] = sm[j]+add[j];
            add[j<<1] = add[j<<1|1] = add[j]<<1;
        }
        for (int j = 0; j < n; ++j) {
            X[n+fSw+j] = gr[i][sm[n+j]];
            Y[n+fSw+j] = gr[i][sm[n+j]+add[n+j]];
        }
    }

    // for (int i = 0; i <= M; ++i) {
    //     cerr << C[i] << ' ';
    // }
    // cerr << endl;
    // for (int i = 0; i < (int) X.size(); ++i) {
    //     cerr << X[i] << ' ' << Y[i] << endl;
    // }
    answer(C, X, Y);
}
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 4940 KB wrong motion
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 4940 KB wrong motion
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 4940 KB wrong motion
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 4940 KB wrong motion
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 5068 KB wrong motion
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 5068 KB wrong motion
2 Halted 0 ms 0 KB -