Submission #76487

# Submission time Handle Problem Language Result Execution time Memory
76487 2018-09-13T16:38:30 Z idLe Mechanical Doll (IOI18_doll) C++14
0 / 100
70 ms 4660 KB
#include "doll.h"
#include <bits/stdc++.h>
using namespace std;

#define LL (nod << 1)
#define RR (LL | 1)
const int NMAX = 100010;
int arb[8*NMAX], N, _N;
bool switches[8*NMAX], last;
vector <int> X, Y, C;

void dfs(int nod, int st, int dr, int trig){
    if (st == dr){
        C[trig] = -1;
        if (nod & 1) Y[nod/2] = trig;
        else X[nod/2] = trig;
        switches[nod] = !switches[nod];
        return;

    }
    int mid = (st + dr) >> 1;
    if (switches[nod]) dfs(RR, mid+1, dr, trig);
    else dfs(LL, st, mid, trig);
    switches[nod] = !switches[nod];
}

void build(int nod, int st, int dr){
    if (st == dr){
        X[nod/2] = Y[nod/2] = -1;
        //if (nod & 1) Y[nod/2] = st;
        //else X[nod/2] = st;
        //if (st == N) C[nod] = 0;
        //else C[nod] = -1;
        return;
    }
    int mid = (st + dr) >> 1;
    X[nod] = -LL; Y[nod] = -RR;
    build(LL, st, mid);
    build(RR, mid + 1, dr);
}

void create_circuit(int M, vector<int> A){
    _N = A.size();
    while (1<<N < _N) N++;
    N = (1<<N);
    C = vector<int>(M+1);
    X = vector<int>(N);
    Y = vector<int>(N);
    C[0] = -1;
    build(1, 1, N);
    for (int i=0; i<A.size(); i++){
        if (i == A.size() - 1) last = 1;
        dfs(1, 1, N, A[i]);
    }
    X.erase(X.begin()); Y.erase(Y.begin());
    Y.back() = 0;
    //for (auto it: C) cout << it << " ";
    //cout << "\n";
    //for (auto it: X) cout << it << " ";
    //cout << "\n";
    //for (auto it: Y) cout << it << " ";
    //cout << "\n";
    answer(C, X, Y);
}

Compilation message

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:51:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |     for (int i=0; i<A.size(); i++){
      |                   ~^~~~~~~~~
doll.cpp:52:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |         if (i == A.size() - 1) last = 1;
      |             ~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB wrong motion
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 2 ms 204 KB Output is partially correct
2 Incorrect 70 ms 4660 KB wrong motion
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 2 ms 204 KB Output is partially correct
2 Incorrect 70 ms 4660 KB wrong motion
3 Halted 0 ms 0 KB -