Submission #1159191

#TimeUsernameProblemLanguageResultExecution timeMemory
1159191KluydQThe Potion of Great Power (CEOI20_potion)C++20
0 / 100
31 ms13380 KiB
#include <bits/stdc++.h>

#define respagold ios_base::sync_with_stdio(0), cin.tie(0);
//#define int long long
#define ll long long
#define int2 __int128_t
#define FOR( i, x, n, d ) for( int i = x; i <= n; i += d )
#define FORR( i, x, n, d ) for( int i = x; i >= n; i -= d )
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x.size())
#define pb push_back
#define ins insert
#define lb lower_bound
#define ub upper_bound
#define pii pair <int, int>
#define mkp make_pair
 
using namespace std;

const int N = 2e5 + 123;
const int inf = 1e9;
const int mod = 1e9 + 7;
const double eps = 1e-13;
 
int a[N], b[N], v[N], u[N], n, m, k, z, x, y, w, ans, tp;
set <int> st[N];
vector <int> v1, v2;
map <pii, int> mp;
vector <int> ord;

mt19937 rng( chrono::steady_clock::now().time_since_epoch().count());
 
int rand( int l, int r )
{
    uniform_int_distribution <int> uid( l, r );
    return uid( rng );
}
bool cmp( int i, int j )
{
	if( a[i] < a[j] || (a[i] == a[j] && i < j) ) return 1;
	return 0;
}
void update( int v, int u, int time )
{
	if( st[v].count(u) ) st[v].erase(u), st[u].erase(v);
	else st[v].ins(u), st[u].ins(v);
}
int question( int X, int Y, int V )
{
//	return 0;
	X = b[X], Y = b[Y];
	v1.clear(), v2.clear();
	
	cout << "G\n";
	for( auto i : st[X] ) v1.pb(i);
	for( auto i : st[Y] ) v2.pb(i);
	
	x = 0, y = 0;
	int res = 1e9;
	
	while( x < sz(v1) && y < sz(v2) )
	{
		res = min( res, abs( a[v2[y]] - a[v1[x]] ));
		
		if( a[x] > a[y] && y < sz(v2) ) y ++;
		else x ++;
	}
	return res;
}
void curseChanges( int U, int A[], int B[] )
{
//	return;
	if( tp == 1 )
	{
//		cin >> m;
//		FOR( i, 0, m - 1, 1 ) cin >> v[i] >> u[i];
	}
	else
	{
		m = U;
		FOR( i, 0, m - 1, 1 ) v[i] = A[i], u[i] = B[i];
	}
	FOR( i, 0, m - 1, 1 ) update( b[v[i]], b[u[i]], i );
}
void init( int NN, int D, int H[] )
{
	respagold;
	
	tp = 2;
//	int H[n + 1];
	
	if( tp == 1 )
	{
		cin >> n >> w;
		FOR( i, 0, n - 1, 1 ) ord.pb(i), cin >> a[i], H[i] = a[i];
	}
	else
	{
//		n = NN, w = D;
//		FOR( i, 0, n - 1, 1 ) a[i] = H[i], ord.pb(i);
	}
	sort( all(ord), cmp );
	FOR( i, 0, n - 1, 1 ) a[i] = H[ord[i]], b[ord[i]] = i;
}
#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...