답안 #95019

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
95019 2019-01-26T20:04:33 Z Mohammad_Yasser 자동 인형 (IOI18_doll) C++14
37 / 100
99 ms 10948 KB
#include "doll.h"
#include <bits/stdc++.h>
using namespace std;

struct Graph {
  int S = 1;
  int N;

  vector<int> X, Y, turn;

  void build(int node, int level, int first_turn) {
    if (node > S) {
      turn[node] = first_turn;
      return;
    }

    X[node] = 2 * node;
    Y[node] = 2 * node + 1;
    build(X[node], level + 1, first_turn);
    build(Y[node], level + 1, first_turn + (1 << level));
    X[node] *= -1;
    Y[node] *= -1;
  }

  void build(int n) {
    N = n;
    while ((S + 1) < N) {
      S = 2 * S + 1;
    }
    X.resize(S + 1);
    Y.resize(S + 1);
    turn = vector<int>(2 * S + 1, -1);
    build(1, 0, 0);
  }
} graph;

void create_circuit(int M, std::vector<int> A) {
  graph.build(A.size() + 1);

  vector<int> C(M + 1);
  for (int& x : C) {
    x = -1;
  }

  for (int i = graph.S / 2 + 1; i <= graph.S; ++i) {
    if (graph.turn[-graph.X[i]] < A.size()) {
      graph.X[i] = A[graph.turn[-graph.X[i]]];
    } else {
      graph.X[i] = -1;
    }
    if (graph.turn[-graph.Y[i]] < A.size()) {
      graph.Y[i] = A[graph.turn[-graph.Y[i]]];
    } else {
      graph.Y[i] = -1;
    }
  }
  graph.Y[graph.S] = 0;
  graph.X.erase(graph.X.begin());
  graph.Y.erase(graph.Y.begin());

  answer(C, graph.X, graph.Y);
}

Compilation message

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:46:33: warning: comparison of integer expressions of different signedness: '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |     if (graph.turn[-graph.X[i]] < A.size()) {
doll.cpp:51:33: warning: comparison of integer expressions of different signedness: '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |     if (graph.turn[-graph.Y[i]] < A.size()) {
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 2 ms 204 KB Output is partially correct
2 Partially correct 74 ms 9612 KB Output is partially correct
3 Partially correct 88 ms 9576 KB Output is partially correct
4 Partially correct 87 ms 10036 KB Output is partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 2 ms 204 KB Output is partially correct
2 Partially correct 74 ms 9612 KB Output is partially correct
3 Partially correct 88 ms 9576 KB Output is partially correct
4 Partially correct 87 ms 10036 KB Output is partially correct
5 Partially correct 96 ms 10836 KB Output is partially correct
6 Partially correct 90 ms 10744 KB Output is partially correct
7 Partially correct 91 ms 10948 KB Output is partially correct
8 Partially correct 89 ms 10520 KB Output is partially correct
9 Partially correct 72 ms 9632 KB Output is partially correct
10 Partially correct 87 ms 10524 KB Output is partially correct
11 Partially correct 94 ms 10108 KB Output is partially correct
12 Partially correct 75 ms 9780 KB Output is partially correct
13 Partially correct 81 ms 10176 KB Output is partially correct
14 Partially correct 81 ms 10304 KB Output is partially correct
15 Partially correct 79 ms 10420 KB Output is partially correct
16 Partially correct 3 ms 588 KB Output is partially correct
17 Correct 50 ms 5464 KB Output is correct
18 Partially correct 75 ms 9772 KB Output is partially correct
19 Partially correct 82 ms 9784 KB Output is partially correct
20 Partially correct 91 ms 10412 KB Output is partially correct
21 Partially correct 99 ms 10128 KB Output is partially correct
22 Partially correct 84 ms 10136 KB Output is partially correct