답안 #75734

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
75734 2018-09-10T20:48:41 Z KieranHorgan 자동 인형 (IOI18_doll) C++17
100 / 100
144 ms 16408 KB
#include "doll.h"
#include <bits/stdc++.h>
using namespace std;

vector<int> A, X, Y, C;
int dep[200];
int nextSwitch = -1;
vector<int> AdjList[200005];

int recurseThroughTree(vector<int> b) {
  if(b.size() == 1) return b[0];
  
  int curSwitch = nextSwitch--;

  vector<int> a;
  for(int i = 0; i < b.size(); i+=2)
    a.push_back(b[i]);
  int l = a.back() == -1 ? -1 : recurseThroughTree(a);

  a.clear();
  for(int i = 1; i < b.size(); i+=2)
    a.push_back(b[i]);
  int r = a.back() == -1 ? -1 : recurseThroughTree(a);

  if(X.size() <= abs(curSwitch)-1) X.resize(abs(curSwitch)), Y.resize(abs(curSwitch));
  X[abs(curSwitch)-1] = l;
  Y[abs(curSwitch)-1] = r;

  return curSwitch;
}

int rev(int x, int n) {
  n = __builtin_ctz(n);
  int res = 0;
  for(int i = 0; i < n; i++)
    if(x & (1<<i))
      res |= 1<<(n-1-i);
  return res;
}

void create_circuit(int M, vector<int> A_) {
  int N = A_.size();
  A = A_;
  A.push_back(0);
  C.assign(M+1, -1);

  int dummies = 0;
  while(__builtin_popcount(A.size()+dummies) != 1)
    dummies++;

  vector<int> b;
  int i, j;
  for(i = 0, j = 0; j < A.size() + dummies; j++) {
    if(i >= A.size() || rev(j, A.size()+dummies) < dummies) b.push_back(-1);
    else b.push_back(A[i++]);
  }

  recurseThroughTree(b);

  double score;
  int S = X.size();
  // cerr << S << " " << N+log2(N) << endl;
  if(S <= N + log2(N)) score = 1;
  else if(S <= 2*N) score = 0.5 + 0.4*((2*N - S)/(N-log2(N)))*((2*N - S)/(N-log2(N)));
  else score = 0;
  score *= 100;

  // cout << "Score: " << setprecision(7) << fixed << score << "\t"  ;
  answer(C, X, Y);
}

Compilation message

doll.cpp: In function 'int recurseThroughTree(std::vector<int>)':
doll.cpp:16:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |   for(int i = 0; i < b.size(); i+=2)
      |                  ~~^~~~~~~~~~
doll.cpp:21:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |   for(int i = 1; i < b.size(); i+=2)
      |                  ~~^~~~~~~~~~
doll.cpp:25:15: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   25 |   if(X.size() <= abs(curSwitch)-1) X.resize(abs(curSwitch)), Y.resize(abs(curSwitch));
      |      ~~~~~~~~~^~~~~~~~~~~~~~~~~~~
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:53:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |   for(i = 0, j = 0; j < A.size() + dummies; j++) {
      |                     ~~^~~~~~~~~~~~~~~~~~~~
doll.cpp:54:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |     if(i >= A.size() || rev(j, A.size()+dummies) < dummies) b.push_back(-1);
      |        ~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4940 KB Output is correct
2 Correct 65 ms 9560 KB Output is correct
3 Correct 60 ms 9188 KB Output is correct
4 Correct 5 ms 4940 KB Output is correct
5 Correct 15 ms 6092 KB Output is correct
6 Correct 79 ms 11192 KB Output is correct
7 Correct 4 ms 4940 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4940 KB Output is correct
2 Correct 65 ms 9560 KB Output is correct
3 Correct 60 ms 9188 KB Output is correct
4 Correct 5 ms 4940 KB Output is correct
5 Correct 15 ms 6092 KB Output is correct
6 Correct 79 ms 11192 KB Output is correct
7 Correct 4 ms 4940 KB Output is correct
8 Correct 103 ms 12916 KB Output is correct
9 Correct 100 ms 13060 KB Output is correct
10 Correct 137 ms 16408 KB Output is correct
11 Correct 5 ms 4928 KB Output is correct
12 Correct 5 ms 4940 KB Output is correct
13 Correct 4 ms 4940 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4940 KB Output is correct
2 Correct 65 ms 9560 KB Output is correct
3 Correct 60 ms 9188 KB Output is correct
4 Correct 5 ms 4940 KB Output is correct
5 Correct 15 ms 6092 KB Output is correct
6 Correct 79 ms 11192 KB Output is correct
7 Correct 4 ms 4940 KB Output is correct
8 Correct 103 ms 12916 KB Output is correct
9 Correct 100 ms 13060 KB Output is correct
10 Correct 137 ms 16408 KB Output is correct
11 Correct 5 ms 4928 KB Output is correct
12 Correct 5 ms 4940 KB Output is correct
13 Correct 4 ms 4940 KB Output is correct
14 Correct 138 ms 15324 KB Output is correct
15 Correct 103 ms 12736 KB Output is correct
16 Correct 139 ms 15216 KB Output is correct
17 Correct 4 ms 4940 KB Output is correct
18 Correct 4 ms 4940 KB Output is correct
19 Correct 5 ms 4940 KB Output is correct
20 Correct 134 ms 15440 KB Output is correct
21 Correct 5 ms 4940 KB Output is correct
22 Correct 5 ms 4940 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 4940 KB Output is correct
2 Correct 6 ms 4940 KB Output is correct
3 Correct 5 ms 4940 KB Output is correct
4 Correct 4 ms 4940 KB Output is correct
5 Correct 5 ms 4940 KB Output is correct
6 Correct 5 ms 4940 KB Output is correct
7 Correct 5 ms 4940 KB Output is correct
8 Correct 4 ms 4940 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4940 KB Output is correct
2 Correct 92 ms 12612 KB Output is correct
3 Correct 91 ms 12668 KB Output is correct
4 Correct 130 ms 14192 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4940 KB Output is correct
2 Correct 92 ms 12612 KB Output is correct
3 Correct 91 ms 12668 KB Output is correct
4 Correct 130 ms 14192 KB Output is correct
5 Correct 136 ms 15212 KB Output is correct
6 Correct 144 ms 14992 KB Output is correct
7 Correct 137 ms 15060 KB Output is correct
8 Correct 132 ms 14764 KB Output is correct
9 Correct 112 ms 12620 KB Output is correct
10 Correct 125 ms 14752 KB Output is correct
11 Correct 130 ms 14572 KB Output is correct
12 Correct 89 ms 12608 KB Output is correct
13 Correct 107 ms 12748 KB Output is correct
14 Correct 96 ms 12756 KB Output is correct
15 Correct 97 ms 12816 KB Output is correct
16 Correct 8 ms 5196 KB Output is correct
17 Correct 98 ms 12536 KB Output is correct
18 Correct 124 ms 12688 KB Output is correct
19 Correct 114 ms 12680 KB Output is correct
20 Correct 125 ms 14668 KB Output is correct
21 Correct 124 ms 14444 KB Output is correct
22 Correct 130 ms 14460 KB Output is correct