Submission #1291105

#TimeUsernameProblemLanguageResultExecution timeMemory
1291105dostsCity (JOI17_city)C++20
22 / 100
224 ms36292 KiB
#include "Encoder.h"
#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2")
#define int long long
#define pii pair<int,int>
#define vi vector<int>
#define ff first
#define ss second
#define sp << " " <<
#define all(x) x.begin(),x.end()
#define big(x) ((int)(x.size()))
using namespace std;
const int MOD = 1e9+7, LIM = 1e6+1, inf = 2e9,N = 250000;
vi edges[N],tin(N),tout(N),special(N,0),par(N,0);
int timer = 0;

void dfs(int node,int p) {
	par[node] = p;
	tin[node] = timer++;
	for (auto it : edges[node]) {
		if (it == p) continue;
		dfs(it,node);
	}
	tout[node] = timer-1;
}

void Encode(signed N, signed A[], signed B[])
{
	for (int i = 0;i<N-1;i++) {
		edges[A[i]].push_back(B[i]);
		edges[B[i]].push_back(A[i]);
	}
	dfs(0,0);

	for (int i=0;i<N;i++) {
		int frst = tin[i];
		frst <<= 18;
		frst|=tout[i];
		Code(i,frst);
	}
}
#include "Device.h"
#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2")
#define int long long
#define pii pair<int,int>
#define vi vector<int>
#define ff first
#define ss second
#define sp << " " <<
#define all(x) x.begin(),x.end()
#define big(x) ((int)(x.size()))
using namespace std;
const int MOD = 1e9+7, LIM = 1e6+1, inf = 2e9;

void InitDevice()
{
	return;
}

signed Answer(long long S, long long T)
{
	int tout1 = S&((1LL<<18)-1);
	S>>=18;
	int tin1 = S&((1LL<<18)-1);
	int tout2 = T&((1LL<<18)-1);
	T>>=18;
	int tin2 = T&((1LL<<18)-1);
	if (tin2 <= tin1 && tout2 >= tout1) {
		return 0;
	}
	if (tin1 <= tin2 && tout1 >= tout2) return 1;
	return 2;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...