Submission #125043

# Submission time Handle Problem Language Result Execution time Memory
125043 2019-07-04T13:44:42 Z TuGSGeReL Mechanical Doll (IOI18_doll) C++17
0 / 100
113 ms 21000 KB
#include "doll.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define mp make_pair
#define pub push_back
#define pob pop_back()
#define ss second
#define ff first
#define mt make_tuple
#define pof pop_front()
#define fbo find_by_order
#define ook order_of_key
#define lb lower_bound
#define ub upper_bound

typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
using pll = pair <ll, ll>;
using pii = pair <int, int>;

int st[200001], n, k = 1, cnt, cur = 1;
vector<int> X, Y, C;

void solve(int res, int num, int at)
{
	if ( num == 1 )
	{
		Y[-at - 1] = 0;
		
		if ( res == 2 )
			X[-at - 1] = 0;
		
		else
			X[-at - 1] = -1;
	} else {
		if ( res <= num )
			X[-at - 1] = -1;
		
		else
			X[-at - 1] = -(++cur);
		
		Y[-at - 1] = -(++cur);
		
		if ( res > num )
		{
			solve(res - num, num / 2, X[-at - 1]);
			solve(num, num / 2, Y[-at - 1]);
		} else{
			solve(res, num / 2, Y[-at - 1]);
		}
	}
}

void dfs(int u, int j )
{
	if ( !st[- u - 1] )
	{
		if ( X[- u - 1] == 0 )
		{
			X[- u - 1] = j;
			st[- u - 1] = 1;
		} else {
			st[- u - 1] = 1;
			dfs(X[- u - 1], j);
		}
	} else {
		if ( Y[- u - 1] == 0 )
		{
			Y[- u - 1] = j;
			st[- u - 1] = 0;
		} else {
			st[- u - 1] = 0;
			dfs(Y[- u - 1], j);
		}
	}
}

void create_circuit(int M, vector<int> A) {
	n = A.size();
	
	X.resize(n + n);
	Y.resize(n + n);
	
	while ( k < n )
		k *= 2;
	
	C.pub(A[0]);
	
	for (int i = 1; i <= M; i++)
		C.pub(-1);
	
	solve(n, k / 2, -1);

	for (int i = 1; i < A.size(); i++)
		dfs(-1, A[i]);
	
	answer(C, X, Y);
}	

Compilation message

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:98:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   98 |  for (int i = 1; i < A.size(); i++)
      |                  ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 204 KB Output is partially correct
2 Partially correct 98 ms 7996 KB Output is partially correct
3 Partially correct 110 ms 7944 KB Output is partially correct
4 Runtime error 113 ms 21000 KB Execution killed with signal 11
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 204 KB Output is partially correct
2 Partially correct 98 ms 7996 KB Output is partially correct
3 Partially correct 110 ms 7944 KB Output is partially correct
4 Runtime error 113 ms 21000 KB Execution killed with signal 11