Submission #563939

# Submission time Handle Problem Language Result Execution time Memory
563939 2022-05-18T09:52:44 Z blue City (JOI17_city) C++17
22 / 100
1701 ms 78364 KB
#include "Encoder.h"
#include <vector>
#include <algorithm>
#include <iostream>
#include <set>
using namespace std;

	namespace{
using vi = vector<int>;
using vvi = vector<vi>;
#define sz(x) int(x.size())


const int mx = 250'000;
using ll = long long;
using vll = vector<ll>;

int N;
vi edge[mx];

vll code(mx, 0);

vll dfsind(mx, 0);
vll subtree(mx, 1);
vll fakesubtree(mx, 1);

int ct = -1;







vll getsizes()
{
	double base = 1.000001;
	set<ll> res;

	double curr = 1;
	while(curr <= mx)
	{
		curr *= base;
		res.insert(curr);
	}

	vll resvec;
	for(ll k : res)
		resvec.push_back(k);

	return resvec;
}


vll sizes;



void dfs(int u, int p)
{
	// cerr << "dfs " << u << '\n';
	dfsind[u] = ++ct;
	for(int v : edge[u])
	{
		if(v == p) continue;
		dfs(v, u);
		subtree[u] += subtree[v];
	}
	auto z = lower_bound(sizes.begin(), sizes.end(), (ll) subtree[u]);
	subtree[u] = *z;
	fakesubtree[u] = z - sizes.begin();
}







	}


void Encode(int N_, int A[], int B[])
{
	N = N_;
	sizes = getsizes();

	cerr << sz(sizes) << '\n';

	// for(int z : sizes)
	// 	cerr << z << ' ';
	// cerr << '\n';



	for(int e = 0; e < N-1; e++)
	{
		edge[A[e]].push_back(B[e]);
		edge[B[e]].push_back(A[e]);
	}

	// cerr << "done\n";

	dfs(0, -1);


	// cerr << "done2\n";

	for(int i = 0; i < N; i++)
	{
		// cerr << i << " : " << dfsind[i] << ' ' << subtree[i] << ' ' << ((dfsind[i]<<18) | subtree[i]) << '\n';
		Code(i, (fakesubtree[i] << 18) | dfsind[i]);
	}
}
#include "Device.h"
#include <vector>
#include <algorithm>
#include <iostream>
#include <set>
using namespace std;

namespace
{
	using vi = vector<int>;
	using vvi = vector<vi>;
	using ll = long long;
	using vll = vector<ll>;
	#define sz(x) int(x.size())

	const int mx = 250'000;

	vll getsizes()
	{
		double base = 1.000001;
		set<ll> res;

		double curr = 1;
		while(curr <= mx)
		{
			curr *= base;
			res.insert(curr);
		}

		vll resvec;
		for(ll k : res)
			resvec.push_back(k);

		return resvec;
	}


	vll sizes;

}

void InitDevice()
{
	sizes = getsizes();
}

int Answer(long long S, long long T)
{
	ll s_st = sizes[S>>18];
	ll s_ind = S & ((1<<18) - 1);

	ll t_st = sizes[T>>18];
	ll t_ind = T & ((1<<18) - 1);

	// cerr << S << ' ' << T << " : " << s_ind << ' ' << s_st << " | " << t_ind << ' ' << t_st << "\n";

	if(t_ind <= s_ind && s_ind + s_st <= t_ind + t_st)
		return 0;
	else if(s_ind <= t_ind && t_ind + t_st <= s_ind + s_st)
		return 1;
	else
		return 2;
}
# Verdict Execution time Memory Grader output
1 Correct 1166 ms 42264 KB Output is correct
2 Correct 1166 ms 42188 KB Output is correct
3 Correct 1182 ms 42140 KB Output is correct
4 Correct 1188 ms 42124 KB Output is correct
5 Correct 1176 ms 42032 KB Output is correct
6 Correct 1170 ms 42252 KB Output is correct
7 Correct 1168 ms 42144 KB Output is correct
8 Correct 1186 ms 42096 KB Output is correct
9 Correct 1164 ms 42264 KB Output is correct
10 Correct 1194 ms 42576 KB Output is correct
11 Correct 1174 ms 42144 KB Output is correct
12 Correct 1176 ms 42224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1332 ms 50460 KB Output is correct - L = 183238656
2 Correct 1324 ms 50404 KB Output is correct - L = 182976512
3 Correct 1336 ms 50640 KB Output is correct - L = 183238656
4 Correct 1316 ms 50736 KB Output is correct - L = 183238656
5 Partially correct 1552 ms 64908 KB Output is partially correct - L = 65535737856
6 Partially correct 1581 ms 78100 KB Output is partially correct - L = 65535737856
7 Partially correct 1577 ms 77984 KB Output is partially correct - L = 65535737856
8 Partially correct 1581 ms 78236 KB Output is partially correct - L = 65535737856
9 Partially correct 1502 ms 78260 KB Output is partially correct - L = 65535737856
10 Partially correct 1605 ms 78252 KB Output is partially correct - L = 65535737856
11 Partially correct 1649 ms 78164 KB Output is partially correct - L = 65535737856
12 Partially correct 1701 ms 78232 KB Output is partially correct - L = 65535737856
13 Partially correct 1547 ms 78148 KB Output is partially correct - L = 65535737856
14 Partially correct 1561 ms 77972 KB Output is partially correct - L = 65535737856
15 Correct 1334 ms 57388 KB Output is correct - L = 183238656
16 Correct 1338 ms 57448 KB Output is correct - L = 183238656
17 Correct 1334 ms 57420 KB Output is correct - L = 183238656
18 Partially correct 1549 ms 77852 KB Output is partially correct - L = 65535737856
19 Partially correct 1553 ms 78064 KB Output is partially correct - L = 65535737856
20 Partially correct 1545 ms 77892 KB Output is partially correct - L = 65535737856
21 Partially correct 1565 ms 78312 KB Output is partially correct - L = 65535737856
22 Partially correct 1567 ms 78020 KB Output is partially correct - L = 65535737856
23 Partially correct 1559 ms 78364 KB Output is partially correct - L = 65535737856
24 Partially correct 1572 ms 78252 KB Output is partially correct - L = 65535737856
25 Partially correct 1583 ms 78116 KB Output is partially correct - L = 65535737856
26 Partially correct 1605 ms 78104 KB Output is partially correct - L = 65535737856
27 Partially correct 1581 ms 78196 KB Output is partially correct - L = 65535737856