Submission #934098

#TimeUsernameProblemLanguageResultExecution timeMemory
934098sopaconkCity (JOI17_city)C++17
22 / 100
277 ms34200 KiB
#include "Encoder.h"
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define deb(x) cout<<#x<<": "<<x<<endl;
using lli=long long int;
 
 
static lli aux=0;
void dfs(int n , int par, vector<vector<int>> &adj, vector<pair<lli,lli>> &range ){
	lli ini=aux;
//	deb(n);
//	deb(aux);
//	deb(par);
	aux++;
	
	for(int x: adj[n]){
		if(x==par) continue;
//		deb(x);
		dfs(x, n, adj, range);
 
	}
	lli fin=aux;

	range[n]={ini, fin-1};
}
 
 
void Encode(int N, int A[], int B[])
{
	
	vector<vector<int>> adj (N);
	for(int i=0; i<N-1; ++i){
		adj[A[i]].pb(B[i]);
		adj[B[i]].pb(A[i]);
	}
	vector<pair<lli,lli>> range (N);
	dfs(0,-1,adj, range);
 
 
 
	for (int i = 0; i < N; ++i) {
		lli ini=range[i].first;
		lli fin=range[i].second;
//		deb(i);
//		deb(ini);
//		deb(fin);

		Code(i, ini*250000+fin);
	}
}
#include "Device.h"
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define deb(x) cout<<#x<<": "<<x<<endl;
using lli=long long int;
void InitDevice()
{
}
 
int Answer(long long S, long long T)
{
	lli finS=S%250000;
	lli iniS= (S-finS)/250000;
	lli finT=T%250000;
	lli iniT=(T-finT)/250000;
	if(iniT <= iniS && finS <= finT){
		return 0;
	}
	if(iniS <= iniT && finT <= finS){
		return 1;
	}
	return 2;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...