제출 #221473

#제출 시각아이디문제언어결과실행 시간메모리
221473galca자동 인형 (IOI18_doll)C++14
0 / 100
1 ms204 KiB
#include "doll.h" // N + 1 = 15 // num_bits = 4 // we should have: 1 + 2 + 4 + 8 void create_circuit(int M, std::vector<int> A) { int N = A.size(); std::vector<int> C(M + 1); for (int i = 0; i <= M; ++i) { C[i] = -1; } std::vector<int> X, Y; int num_bits = 0; int tmp = N + 1; while (tmp > 0) { ++num_bits; tmp >>= 1; } int last_layer = 0; for (int k = 1; k < num_bits; ++k) { int n_nodes = 1 << (k-1); for (int n = 0; n < n_nodes; n++) { X.push_back(-n * 2); Y.push_back(-(n * 2 + 1)); } } // N nodes of the last level are connected to the triggers, the last one // 2^bits-N-1 to -1 // and the last one to origin int n_leaves = 1 << (num_bits-1); int idx_b = X.size(); for (int n = 0; n < n_leaves; n++) { X.push_back(-1); X.push_back(-1); } for (int n = 0; n < N; n++) { // revert the number int n_inv = 0; int n_tmp = n; for (int l=0; l<num_bits; l++) { n_inv = (n_inv << 1) | (n_tmp & 1); n_tmp >> 1; } if (n_inv & 1) { Y[idx_b + n_inv/2] = A[n]; } else { X[idx_b + n_inv/2] = A[n]; } } Y[idx_b + n_leaves - 1] = 0; answer(C, X, Y); }

컴파일 시 표준 에러 (stderr) 메시지

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:50:10: warning: statement has no effect [-Wunused-value]
   50 |    n_tmp >> 1;
      |    ~~~~~~^~~~
doll.cpp:24:6: warning: unused variable 'last_layer' [-Wunused-variable]
   24 |  int last_layer = 0;
      |      ^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...