Submission #124508

# Submission time Handle Problem Language Result Execution time Memory
124508 2019-07-03T12:56:33 Z TuGSGeReL Mechanical Doll (IOI18_doll) C++17
10 / 100
123 ms 19392 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];

void create_circuit(int M, vector<int> A) {
	
	
	
	A.pub(0);
	vector<int> C(M + 1);
	set<int> ext;
	for (int i = 1; i <= M; i++)
		C[i] = -1;
	C[0] = A[0];
	ext.insert(1);
	vector<int> X, Y;
	X.pub(1e9);
	Y.pub(1e9);
	
	while (ext.size() * 2 < A.size() - 1 || pow(2, (int)log2(ext.size())) != ext.size() )
	{
		auto it = ext.begin();
		
		while ( X.size() < *it )
			X.pub(1e9), Y.pub(1e9);
		
		X[*it - 1] = -(*it * 2);
		Y[*it - 1] = -(*it * 2 + 1);
		ext.insert(*it * 2);
		ext.insert(*it * 2 + 1);
		while ( *it * 2 + 1 > X.size() )
		{
			X.pub(1e9);
			Y.pub(1e9);
		}
		ext.erase(it);
	}

	int num = 0, u = 0, z = 1, p = 2 * ext.size() - (A.size() - 1);
	
	while ( num < ext.size() * 2 ) 
	{
		if ( (X[u] == 1e9 && !st[u]) || (Y[u] == 1e9 && st[u]) )
		{			
			if ( z < A.size() && !p )
			{
				if ( !st[u] )
				{
					X[u] = A[z++];
					st[u] = 1;
				} else 
				{
					Y[u] = A[z++];
					st[u] = 0;
				}
			} else {
				if ( !st[u] )
				{
					X[u] = -1;
					st[u] = 1;
				} else 
				{
					Y[u] = -1;
					st[u] = 0;
				}
				p--;
			}
			u = 0;
			num++;
		} else {
			if ( st[u] )
			{
				st[u] ^= 1;
				u = -Y[u] - 1;
			} else
				st[u] ^= 1, u = -X[u] - 1;
			
		}
	}
	
//	for (auto x : C)
//		cout << x << " ";
//	
//	cout << "\n";
//	
//	for (auto x : X)
//		cout << x << " ";
//	
//	cout << "\n";
//	
//	for (auto x : Y)
//		cout << x << " ";
//	
//	cout << "\n";
	
	answer(C, X, Y);
}	

Compilation message

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:46:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'const int' [-Wsign-compare]
   46 |   while ( X.size() < *it )
      |           ~~~~~~~~~^~~~~
doll.cpp:53:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |   while ( *it * 2 + 1 > X.size() )
      |           ~~~~~~~~~~~~^~~~~~~~~~
doll.cpp:63:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::set<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |  while ( num < ext.size() * 2 )
      |          ~~~~^~~~~~~~~~~~~~~~
doll.cpp:67:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |    if ( z < A.size() && !p )
      |         ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 2 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 2 ms 204 KB Output is correct
8 Correct 1 ms 276 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 204 KB Output is partially correct
2 Correct 123 ms 8624 KB Output is correct
3 Runtime error 85 ms 19392 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 204 KB Output is partially correct
2 Correct 123 ms 8624 KB Output is correct
3 Runtime error 85 ms 19392 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -