Submission #76025

# Submission time Handle Problem Language Result Execution time Memory
76025 2018-09-11T20:21:18 Z idLe Mechanical Doll (IOI18_doll) C++14
0 / 100
2 ms 204 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;
bool switches[8*NMAX], last;
vector <int> X, Y, C;

void dfs(int nod, int st, int dr, int trig){
    if (st == dr){
        if (last) C[trig] = 0;
        else 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();
    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());
    //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:50:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |     for (int i=0; i<A.size(); i++){
      |                   ~^~~~~~~~~
doll.cpp:51:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |         if (i == A.size() - 1) last = 1;
      |             ~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 204 KB wrong motion
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 204 KB wrong motion
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 204 KB wrong motion
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB wrong motion
3 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 Incorrect 1 ms 204 KB wrong motion
2 Halted 0 ms 0 KB -