답안 #1060598

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1060598 2024-08-15T18:15:24 Z Joshua_Andersson 자동 인형 (IOI18_doll) C++14
0 / 100
160 ms 16320 KB
#include "doll.h"

#include <bits/stdc++.h>
using namespace std;

const int inf = int(1e9);

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> p2;

#define rep(i, high) for (int i = 0; i < high; i++)
#define repp(i, low, high) for (int i = low; i < high; i++)
#define repe(i, container) for (auto& i : container)
#define sz(container) ((int)container.size())
#define all(x) begin(x),end(x)

#if _LOCAL
#define assert(x) if (!(x)) __debugbreak()
#endif

map<int,int> ind;
vi state;
vi x, y;
int k = 18;
void build_tree(int u, int d, vi& x, vi& y)
{
	if (d==0)
	{
		x[u] = inf;
		y[u] = inf;
		return;
	}
	x[u] = u * 2;
	y[u] = u * 2 + 1;
	build_tree(u * 2, d - 1, x, y);
	build_tree(u * 2+1, d - 1, x, y);
}

void traverse(int u, int t)
{
	int& v = state[u]?y[u]:x[u];
	state[u] ^= 1;
	if (v==inf)
	{
		v = t;
		return;
	}
	traverse(v, t);
}

void create_circuit(int m, std::vector<int> a)
{
	int n = sz(a);
	vi c(m + 1, -1);

	state.resize(1<<k+1);
	x.resize(1 << k+1, inf);
	y.resize(1 << k+1, inf);
	build_tree(1, k, x, y);
	rep(i, n)
	{
		traverse(1, a[i]);
	}
	repp(i, n, (1 << k+1)-1)
	{
		traverse(1, -1);
	}
	traverse(1, 0);
	rep(i, 1 << k) x[i] *= -1, y[i] *= -1;
	repp(i, 1<<k, sz(x))
	{
		if (x[i] == inf) x[i] = -1;
		if (y[i] == inf) y[i] = -1;
	}
	x.erase(x.begin());
	y.erase(y.begin());
	answer(c, x, y);
}

Compilation message

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:57:19: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   57 |  state.resize(1<<k+1);
      |                  ~^~
doll.cpp:58:17: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   58 |  x.resize(1 << k+1, inf);
      |                ~^~
doll.cpp:59:17: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   59 |  y.resize(1 << k+1, inf);
      |                ~^~
doll.cpp:65:20: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   65 |  repp(i, n, (1 << k+1)-1)
      |                   ~^~
doll.cpp:13:50: note: in definition of macro 'repp'
   13 | #define repp(i, low, high) for (int i = low; i < high; i++)
      |                                                  ^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 151 ms 16320 KB over 400000 switches
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 151 ms 16320 KB over 400000 switches
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 151 ms 16320 KB over 400000 switches
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 160 ms 16304 KB over 400000 switches
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 150 ms 16316 KB over 400000 switches
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 150 ms 16316 KB over 400000 switches
2 Halted 0 ms 0 KB -