Submission #61109

# Submission time Handle Problem Language Result Execution time Memory
61109 2018-07-25T08:12:11 Z 노영훈(#1760) City (JOI17_city) C++11
8 / 100
191 ms 40632 KB
#include "Encoder.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int MX=250010;

vector<int> G[MX];
int n, nu[MX], ri[MX];

void dfs(int v, int p=-1){
	static int now=0;
	nu[v]=++now, ri[v]=nu[v];
	for(int x:G[v]){
		if(x==p) continue;
		dfs(x,v);
		ri[v]=max(ri[v], ri[x]);
	}
}

void Encode(int N, int A[], int B[]){
	n=N;
	for(int i=0; i<n-1; i++){
		int u=A[i], v=B[i];
		G[u].push_back(v);
		G[v].push_back(u);
	}
	dfs(0,-1);
	for(int i=0; i<n; i++){
		ll now=(nu[i]<<18LL)+ri[i];
		Code(i, now);
	}
}
#include "Device.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

void InitDevice(){
}

int Answer(long long S, long long T){
	int u=S/(1<<18), ru=S%(1<<18);
	int v=T/(1<<18), rv=T%(1<<18);
	// cout<<u<<' '<<v<<' '<<'\n';
	if(u<=v && v<=ru) return 1;
	if(v<=u && u<=rv) return 0;
	return 2;
}
# Verdict Execution time Memory Grader output
1 Correct 8 ms 12288 KB Output is correct
2 Correct 8 ms 12544 KB Output is correct
3 Correct 7 ms 12544 KB Output is correct
4 Correct 8 ms 12472 KB Output is correct
5 Correct 8 ms 12288 KB Output is correct
6 Correct 9 ms 12544 KB Output is correct
7 Correct 9 ms 12488 KB Output is correct
8 Correct 8 ms 12544 KB Output is correct
9 Correct 9 ms 12488 KB Output is correct
10 Correct 7 ms 12288 KB Output is correct
11 Correct 10 ms 12488 KB Output is correct
12 Correct 8 ms 12288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 172 ms 19576 KB Output is correct - L = 183501500
2 Correct 168 ms 19440 KB Output is correct - L = 183239355
3 Correct 170 ms 19440 KB Output is correct - L = 183501500
4 Correct 170 ms 19440 KB Output is correct - L = 183501500
5 Incorrect 191 ms 40632 KB Wrong Answer [3]
6 Halted 0 ms 0 KB -