답안 #414348

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
414348 2021-05-30T11:08:55 Z DBPhoenix 자동 인형 (IOI18_doll) C++17
6 / 100
131 ms 19872 KB
#include "doll.h"
#include <bits/stdc++.h>

using namespace std;

struct Tree {
  int pointer = 1;
  vector<int> nodes = {0};
};

int switches = 0;
Tree tree[200001];

void insert(int i, int value)
{
  if (tree[i].pointer == 1) {
    tree[i].nodes.push_back(value);
    tree[i].pointer++;
    return;
  }

  if (tree[i].nodes[tree[i].pointer / 2] > -1) {
    tree[i].nodes.push_back(tree[i].nodes[tree[i].pointer / 2]);
    tree[i].nodes[tree[i].pointer / 2] = -(++switches);
    tree[i].pointer++;
  }
  
  tree[i].nodes.push_back(value);
  tree[i].pointer++;
}

void create_circuit(int M, std::vector<int> A) {
  int N = A.size();

  int prev = 0;
  for (int a : A)
  {
    insert(prev, a);
    prev = a;
  }
  insert(prev, 0);

  vector<int> C(M + 1);
  for (int i = 0; i <= M; ++i)
  {
    if (tree[i].nodes.size() < 2)
      C[i] = 1;
    else
      C[i] = tree[i].nodes[1];
  }

  vector<int> X(switches);
  vector<int> Y(switches);
  for (int i = 0; i <= M; i++)
  {
    for (int j = 1; true; j++)
      if (tree[i].nodes[j] > -1) break;
      else
      {
        X[-tree[i].nodes[j] - 1] = tree[i].nodes[j * 2];
        Y[-tree[i].nodes[j] - 1] = tree[i].nodes[j * 2 + 1];
      }
  }

  answer(C, X, Y);
}

Compilation message

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:33:7: warning: unused variable 'N' [-Wunused-variable]
   33 |   int N = A.size();
      |       ^
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 12748 KB Output is correct
2 Correct 49 ms 14484 KB Output is correct
3 Correct 47 ms 14020 KB Output is correct
4 Correct 18 ms 12736 KB Output is correct
5 Correct 34 ms 13900 KB Output is correct
6 Correct 78 ms 14736 KB Output is correct
7 Correct 16 ms 12748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 12748 KB Output is correct
2 Correct 49 ms 14484 KB Output is correct
3 Correct 47 ms 14020 KB Output is correct
4 Correct 18 ms 12736 KB Output is correct
5 Correct 34 ms 13900 KB Output is correct
6 Correct 78 ms 14736 KB Output is correct
7 Correct 16 ms 12748 KB Output is correct
8 Correct 113 ms 16168 KB Output is correct
9 Correct 85 ms 16020 KB Output is correct
10 Correct 131 ms 17828 KB Output is correct
11 Correct 19 ms 12748 KB Output is correct
12 Correct 15 ms 12748 KB Output is correct
13 Correct 17 ms 12748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 12748 KB Output is correct
2 Correct 49 ms 14484 KB Output is correct
3 Correct 47 ms 14020 KB Output is correct
4 Correct 18 ms 12736 KB Output is correct
5 Correct 34 ms 13900 KB Output is correct
6 Correct 78 ms 14736 KB Output is correct
7 Correct 16 ms 12748 KB Output is correct
8 Correct 113 ms 16168 KB Output is correct
9 Correct 85 ms 16020 KB Output is correct
10 Correct 131 ms 17828 KB Output is correct
11 Correct 19 ms 12748 KB Output is correct
12 Correct 15 ms 12748 KB Output is correct
13 Correct 17 ms 12748 KB Output is correct
14 Incorrect 119 ms 19872 KB state 'Y'
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 16 ms 12748 KB state 'Y'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 16 ms 12748 KB state 'Y'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 16 ms 12748 KB state 'Y'
2 Halted 0 ms 0 KB -