Submission #278766

# Submission time Handle Problem Language Result Execution time Memory
278766 2020-08-21T20:45:17 Z doowey Mechanical Doll (IOI18_doll) C++14
0 / 100
1 ms 204 KB
#include <bits/stdc++.h>
#include "doll.h"

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

#define fi first
#define se second
#define mp make_pair

int n;

const int N = (int)2e5 + 10;
int x[N], y[N];
int flip[N];
int id = 1;
int p = 1;

int build(int l, int r){
    if(l >= r) return 0;
    if(r + n <= p - 1) return -1;
    int cur = id++;
    int mid = (l + r) / 2;
    x[cur] = build(l, mid);
    y[cur] = build(mid + 1, r);
    return -cur;
}

void put(int xv){
    int cur = -1;
    int real;
    int nx;
    while(1){
        real = -cur;
        if(flip[real]){
            nx = y[real];
            flip[real] = false;
            if(nx == 0){
                y[real] = xv;
                return;
            }
            else{
                cur = nx;
            }
        }
        else{
            nx = x[real];
            flip[real] = true;
            if(nx == 0){
                x[real] = xv;
                return;
            }
            else{
                cur = nx;
            }
        }
    }
}

void create_circuit(int M, vector<int> A) {
    n = A.size();
    if(n == 1){
        vector<int> cc;
        cc.push_back(A[0]);
        for(int i = 1; i <= M ; i ++ )
            cc.push_back(0);
        answer(cc, {}, {});
        return ;
    }
    while(p < n)
        p *= 2;
    build(0, p - 1);
    vector<int> C(M + 1);
    C[0] = A[0];
    for(int i = 1; i <= M; i ++ )
        C[i] = -1;
    for(int i = 1; i < n ; i ++ )
        put(A[i]);
    if(n % 2 == 1)
        put(-1);
    put(0);
    vector<int> xx, yy;
    for(int i = 1; i < id; i ++ ){
        xx.push_back(x[i]);
        yy.push_back(y[i]);
    }
    for(auto x : C) cout << x << " ";
    cout << "\n";
    for(int i = 0; i < xx.size(); i ++ ){
        cout << xx[i] << " | " << yy[i] << "\n";
    }
    answer(C, xx, yy);
}

Compilation message

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:91:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   91 |     for(int i = 0; i < xx.size(); i ++ ){
      |                    ~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB DO NOT PRINT ANYTHING TO STANDARD OUTPUT
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB DO NOT PRINT ANYTHING TO STANDARD OUTPUT
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB DO NOT PRINT ANYTHING TO STANDARD OUTPUT
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB DO NOT PRINT ANYTHING TO STANDARD OUTPUT
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB DO NOT PRINT ANYTHING TO STANDARD OUTPUT
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB DO NOT PRINT ANYTHING TO STANDARD OUTPUT
2 Halted 0 ms 0 KB -