Submission #926398

#TimeUsernameProblemLanguageResultExecution timeMemory
926398amirhoseinfar1385City (JOI17_city)C++17
18 / 100
321 ms53576 KiB
#include "Encoder.h"
#include<bits/stdc++.h>
using namespace std;
vector<vector<int>>adj;
vector<pair<int,int>>stf;
int timea=0;
void solve(int u,int par=-1){
	timea++;
	stf[u].first=timea;
	for(auto x:adj[u]){
		if(x!=par){
			solve(x,u);
		}
	}
	stf[u].second=timea;
}

void Encode(int N, int A[], int B[])
{
	adj.clear();
	stf.clear();
	adj.resize(N+1);
	stf.resize(N+1);
	timea=0;
	for (int i = 0; i < N-1; ++i) {
		adj[A[i]].push_back(B[i]);
		adj[B[i]].push_back(A[i]);
	}
	solve(0);
	for(int i=0;i<N;i++){
		Code(i,stf[i].first+(stf[i].second*(1ll<<19)));
	}
}
#include "Device.h"
#include<bits/stdc++.h>
using namespace std;

void InitDevice()
{
}

int Answer(long long S, long long T)
{
	pair<long long ,long long>stfs,stft;
	stfs.first=(((1<<19)-1)&S);
	stft.first=(((1<<19)-1)&T);
	S>>=19;
	T>>=19;
	stfs.second=S;
	stft.second=T;
	if(stft.first>=stfs.first&&stft.second<=stfs.second){
		return 1;
	}
	if(stfs.first>=stft.first&&stfs.second<=stft.second){
		return 0;
	}
	return 2;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...