답안 #832443

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
832443 2023-08-21T10:24:37 Z caganyanmaz 자동 인형 (IOI18_doll) C++17
60.6719 / 100
58 ms 8536 KB
#include <bits/stdc++.h>
#define pb push_back
#include "doll.h"
using namespace std;

//#define DEBUGGING
#ifdef DEBUGGING
#include "../debug.h"
#else
#define debug(x...) void(42)
#endif

vector<int> a;
vector<int> x, y;
int n, m;


void create_circuit(int M, vector<int> A) 
{
	a = A;
	if (a.size() == (a.size()&(-a.size())))
		a.pb(0);
	n = a.size();
	int step_count = (a.size()+1)/2;
	int i;
	for (i = 0; i+step_count < a.size(); i++)
	{
		x.pb(a[i]);
		y.pb(a[i+step_count]);
	}
	if (n&1)
	{
		x.pb(a[i]);
		y.pb(0);
	}
	int l = 0, r = x.size();
	int depth = 0;
	while ((r-l) > 1)
	{
		depth++;
		step_count = (r+1 - l)/2;
		for (i = l; i+step_count < r; i++)
		{
			x.pb(-i-1);
			y.pb(-i-step_count-1);
		}
		if (1&(r-l))
		{
			x.pb(-i-1);
			y.pb(0);
		}
		l = r;
		r = x.size();
	}
	int root = -x.size();
	for (int i = 0; i < x.size(); i++)
	{
		if (x[i] == 0)
			x[i] = root;
		if (y[i] == 0)
			y[i] = root;
	}
	int last = root;
	i = x.size()-1;
	int d = 0;
	while (y[i] != root)
	{
		d++;
		i = -y[i]-1;
	}
	y[i] = -x.size()-1;
	int last_encounter = i;
	while (d < depth)
	{
		int xsize = x.size();
		d++;
		x.pb(last);
		y.pb(-xsize-2);
		last_encounter = y.size()-1;
	}
	y[last_encounter] = 0;
	vector<int> c(M+1, root);
	debug(c, x, y);
	answer(c, x, y);
}

Compilation message

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:26:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |  for (i = 0; i+step_count < a.size(); i++)
      |              ~~~~~~~~~~~~~^~~~~~~~~~
doll.cpp:56:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |  for (int i = 0; i < x.size(); i++)
      |                  ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 1 ms 212 KB Output is partially correct
2 Partially correct 29 ms 5744 KB Output is partially correct
3 Partially correct 29 ms 5720 KB Output is partially correct
4 Partially correct 43 ms 7800 KB Output is partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 1 ms 212 KB Output is partially correct
2 Partially correct 29 ms 5744 KB Output is partially correct
3 Partially correct 29 ms 5720 KB Output is partially correct
4 Partially correct 43 ms 7800 KB Output is partially correct
5 Partially correct 52 ms 8536 KB Output is partially correct
6 Partially correct 49 ms 8168 KB Output is partially correct
7 Partially correct 51 ms 8300 KB Output is partially correct
8 Partially correct 47 ms 7936 KB Output is partially correct
9 Partially correct 30 ms 5712 KB Output is partially correct
10 Partially correct 48 ms 7992 KB Output is partially correct
11 Partially correct 45 ms 7608 KB Output is partially correct
12 Partially correct 34 ms 5980 KB Output is partially correct
13 Partially correct 33 ms 6360 KB Output is partially correct
14 Partially correct 36 ms 6620 KB Output is partially correct
15 Partially correct 40 ms 6628 KB Output is partially correct
16 Partially correct 1 ms 468 KB Output is partially correct
17 Correct 30 ms 5216 KB Output is correct
18 Partially correct 30 ms 5884 KB Output is partially correct
19 Partially correct 30 ms 5884 KB Output is partially correct
20 Partially correct 46 ms 7692 KB Output is partially correct
21 Partially correct 48 ms 7628 KB Output is partially correct
22 Partially correct 58 ms 7640 KB Output is partially correct