Submission #75351

# Submission time Handle Problem Language Result Execution time Memory
75351 2018-09-09T11:22:32 Z gs14004 Mechanical Doll (IOI18_doll) C++17
0 / 100
2 ms 204 KB
#include "doll.h"
#include <bits/stdc++.h>
using namespace std;

void dfs(int r, vector<int> &X, vector<int> &Y, vector<int> A){
	if(A.size() == 2){
		X[r-1] = A[0];
		Y[r-1] = A[1];
		return;
	}
	vector<int> L, R;
	for(int i=0; i<A.size(); i++){
		if(i & 1) R.push_back(A[i]);
		else L.push_back(A[i]);
	}
	X[r-1] = -2 * r;
	Y[r-1] = -2 * r - 1;
	dfs(2 * r, X, Y, L);
	dfs(2 * r + 1, X, Y, R);
}

void create_circuit(int M, std::vector<int> A) {
	if(A.size() == 1){
		vector<int> C(M + 1, 0), X, Y;
		C[0] = A[0];
		answer(C, X, Y);
		return;
	}
	vector<int> C(M + 1, -1);
	C[0] = A[0];
	A.erase(A.begin());
	int K = 0;
	while((1 << K) < A.size() + 1) K++;
	while(A.size() < (1 << K) - 1){
		A.push_back(-1);
	}
	A.push_back(0);
	vector<int> X(A.size() - 1), Y(A.size() - 1);
	cout << A.size() - 1 << endl;
	dfs(1, X, Y, A);
	answer(C, X, Y);
}

Compilation message

doll.cpp: In function 'void dfs(int, std::vector<int>&, std::vector<int>&, std::vector<int>)':
doll.cpp:12:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |  for(int i=0; i<A.size(); i++){
      |               ~^~~~~~~~~
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:33:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |  while((1 << K) < A.size() + 1) K++;
      |        ~~~~~~~~~^~~~~~~~~~~~~~
doll.cpp:34:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   34 |  while(A.size() < (1 << K) - 1){
      |        ~~~~~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 204 KB DO NOT PRINT ANYTHING TO STANDARD OUTPUT
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 204 KB DO NOT PRINT ANYTHING TO STANDARD OUTPUT
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 204 KB DO NOT PRINT ANYTHING TO STANDARD OUTPUT
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB DO NOT PRINT ANYTHING TO STANDARD OUTPUT
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB DO NOT PRINT ANYTHING TO STANDARD OUTPUT
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB DO NOT PRINT ANYTHING TO STANDARD OUTPUT
2 Halted 0 ms 0 KB -