Submission #774157

# Submission time Handle Problem Language Result Execution time Memory
774157 2023-07-05T12:26:53 Z pashka Mechanical Doll (IOI18_doll) C++14
0 / 100
1 ms 296 KB
#include "doll.h"
#include<iostream>

using namespace std;

int reverse(int x, int k) {
    int y = 0;
    for (int i = 0;i < k; i++) {
        y = (y * 2) + (x % 2);
        x /= 2;
    }
    return y;
}

void create_circuit(int M, std::vector<int> A) {
    int n = A.size();
    int k = 0;
    while ((1 << (k + 1)) < n + 1) {
        k++;
    }
    vector<int> x((1 << (k + 1)) - 1), y((1 << (k + 1)) - 1);
    for (int i = 0; i < (1 << k) - 1; i++) {
        x[i] = -((2 * i + 1) + 1);
        y[i] = -((2 * i + 2) + 1);
    }
    for (int i = 0; i < (1 << k); i++) {
        int t = reverse(2 * i, k + 1);
        if (t < n) {
            t = A[t];
        } else {
            t = -1;
        }
        x[(1 << k) - 1 + i] = t;
        t = reverse(2 * i + 1, k + 1);
        if (t < n) {
            t = A[t];
        } else if (i == (1 << k) - 1) {
            t = 0;
        } else {
            t = -1;
        }
        y[(1 << k) - 1 + i] = t;
    }
    vector<int> c(M + 1, -1);
    for (int i = 0; i < x.size(); i++) {
        cout << x[i] << " " << y[i] << "\n";
    }
    answer(c, x, y);
}

Compilation message

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