Submission #1335332

#TimeUsernameProblemLanguageResultExecution timeMemory
1335332blackscreen1Mechanical Doll (IOI18_doll)C++20
100 / 100
99 ms12420 KiB
#include "doll.h"
#include <bits//stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less<long long>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_multiset;
#define ll long long
#define iloop(m, h) for (auto i = m; i != h; i += (m < h ? 1 : -1))
#define jloop(m, h) for (auto j = m; j != h; j += (m < h ? 1 : -1))
#define kloop(m, h) for (auto k = m; k != h; k += (m < h ? 1 : -1))
#define lloop(m, h) for (auto l = m; l != h; l += (m < h ? 1 : -1))
#define pll pair<ll, ll>
#define INF 1000000000000000
#define MOD1 1000000007
#define MOD2 998244353
#define MOD3 1000000009
ll n, m, ccn = 0, st = 0;
ll l[200205], r[200205], pnd;
vector<int> c, x, y;
bool isl[200205];
ll cons(ll cc, ll cr) {
	if (cc == 0) return -1;
	if (cr == 1) return 1;
	ll ci = ++ccn;
	if (cc < cr>>1) r[ci] = cons(cc, cr>>1), l[ci] = -1;
	else r[ci] = cons(cr>>1, cr>>1), l[ci] = cons(cc - (cr>>1), cr>>1);
	return -ci;
}
void qu(ll ci, ll to) {
	//cout << "v " << ci << " " << to << endl;
	isl[ci] ^= 1;
	if (isl[ci]) {
		if (l[ci] < 0) qu(-l[ci], to);
		else x[ci-1] = to;
	}
	else {
		if (r[ci] < 0) qu(-r[ci], to);
		else y[ci-1] = to;
	}
}
void create_circuit(int M, vector<int> A) {
	n = A.size(), m = M;
	while ((1<<st) < n + 1) st++;
	cons(n + 1, 1<<st);
	iloop(0, m + 1) c.push_back(-1);
	iloop(0, ccn) x.push_back(l[i+1]), y.push_back(r[i+1]);
	/*for (auto it : x) cout << it << " ";
	cout << endl;
	for (auto it : y) cout << it << " ";
	cout << endl;*/
	for (auto it : A) qu(1, it);
	qu(1, 0);
	answer(c, x, y);
	/*for (auto it : c) cout << it << " ";
	cout << endl;
	for (auto it : x) cout << it << " ";
	cout << endl;
	for (auto it : y) cout << it << " ";
	cout << endl;*/
	return;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...