답안 #463823

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
463823 2021-08-11T20:49:07 Z tomsyd 자동 인형 (IOI18_doll) C++17
37 / 100
109 ms 10800 KB
#include "doll.h"
#include<bits/stdc++.h>
using namespace std;

int rev(int node, int nb){
	int ans = 0;
	for (int i=0; i<nb; ++i){
		if (node&(1<<i)){
			ans += (1<<(nb-1-i));
		}
	}
	return ans;
}

void create_circuit(int M, vector<int> bisA) {
	deque<int> A;
	for (int i:bisA) A.emplace_back(i);
	int pow2 = 1, N = A.size();
   vector<int> C(M+1,-1);
	if(N == 1){
		C = vector<int>(M+1);
		vector<int> da,db;
		C[0] = A[0];
		C[A[0]] = 0;
		answer(C,da,db);
      return;
   }
	int nb = 0;
	while (pow2 < N+1){
		nb++;
		pow2 *= 2;
	}
	A.emplace_back(0);
	while (A.size() < pow2) A.emplace_front(-1);
	pow2 /= 2;
	vector<int> X(2*pow2-1,-1),Y(2*pow2-1,-1);
	for (int i=0; i<pow2-1; ++i){
		X[i] = -(2*(i+1));
		Y[i] = -(2*(i+1)+1);
	}
/*	cout << "A : ";
	for (int i:A) cout << i << ' ';
	cout << endl;
*/	for(int idx=pow2-1, id = 0; idx<X.size(); ++idx, ++id){
		X[idx] = A[rev(2*id,nb)];
		Y[idx] = A[rev(2*id+1,nb)];
	}
/*	for (int i=0; i<X.size(); ++i){
		cout << -i-1 << " : " << X[i] << ' ' << Y[i] << endl;
	}
*/	answer(C,X,Y);
}

Compilation message

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:34:18: warning: comparison of integer expressions of different signedness: 'std::deque<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   34 |  while (A.size() < pow2) A.emplace_front(-1);
      |         ~~~~~~~~~^~~~~~
doll.cpp:44:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 | */ for(int idx=pow2-1, id = 0; idx<X.size(); ++idx, ++id){
      |                                ~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 204 KB Output is partially correct
2 Partially correct 86 ms 8572 KB Output is partially correct
3 Partially correct 83 ms 8572 KB Output is partially correct
4 Partially correct 103 ms 9008 KB Output is partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 204 KB Output is partially correct
2 Partially correct 86 ms 8572 KB Output is partially correct
3 Partially correct 83 ms 8572 KB Output is partially correct
4 Partially correct 103 ms 9008 KB Output is partially correct
5 Partially correct 98 ms 9516 KB Output is partially correct
6 Partially correct 97 ms 10720 KB Output is partially correct
7 Partially correct 99 ms 10800 KB Output is partially correct
8 Partially correct 96 ms 10648 KB Output is partially correct
9 Partially correct 83 ms 9428 KB Output is partially correct
10 Partially correct 95 ms 10576 KB Output is partially correct
11 Partially correct 94 ms 10552 KB Output is partially correct
12 Partially correct 84 ms 9476 KB Output is partially correct
13 Partially correct 109 ms 9548 KB Output is partially correct
14 Partially correct 87 ms 9680 KB Output is partially correct
15 Partially correct 94 ms 9796 KB Output is partially correct
16 Partially correct 3 ms 588 KB Output is partially correct
17 Correct 52 ms 5828 KB Output is correct
18 Partially correct 93 ms 9412 KB Output is partially correct
19 Partially correct 85 ms 9496 KB Output is partially correct
20 Partially correct 100 ms 10532 KB Output is partially correct
21 Partially correct 95 ms 10548 KB Output is partially correct
22 Partially correct 98 ms 10516 KB Output is partially correct