답안 #67458

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
67458 2018-08-14T10:14:51 Z reality City (JOI17_city) C++17
8 / 100
171 ms 19400 KB
#include "Encoder.h"
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define vii vector < pii >
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class P , class Q > ostream& operator<<(ostream& stream, pair < P , Q > v){ stream << "(" << v.fi << ',' << v.se << ")"; return stream;}
template < class T > ostream& operator<<(ostream& stream, const vector<T> v){ stream << "[ "; for (int i=0; i<(int)v.size(); i++) stream << v[i] << " "; stream << "]"; return stream;}
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}

static const int N = 250000;

vi g[N + 69];

ll Time = 0;

static const db w = 1.04367;

static map < ll , int > M;

static int T = -1;

void dfs(int node = 0,int prev = -1) {
	int beg = ++T;
	for (auto it : g[node])
		if (it != prev)
			dfs(it,node);
	int len = T - beg;
	int sz = M.lower_bound(len)->se;
	Code(node,1ll * sz * N + beg);
}


void Encode(int NN, int A[], int B[]) {
	int n = NN;
	for (int i = 0;i + 1 < n;++i) {
		g[A[i]].pb(B[i]);
		g[B[i]].pb(A[i]);
	}
	M[0] = 0;
	M[1] = 1;
	db o = 1;
	int sz = 1;
	do {
		o *= w;
		ll u = (ll)(o);
		if (!M.count(u))
			M[u] = ++sz;
	} while (o <= N * 2);
	dfs();
}
#include "Device.h"
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define vii vector < pii >
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class P , class Q > ostream& operator<<(ostream& stream, pair < P , Q > v){ stream << "(" << v.fi << ',' << v.se << ")"; return stream;}
template < class T > ostream& operator<<(ostream& stream, const vector<T> v){ stream << "[ "; for (int i=0; i<(int)v.size(); i++) stream << v[i] << " "; stream << "]"; return stream;}
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}

static const int N = 250000;

static const db w = 1.04367;

static map < ll , int > M;

static int len[N];

void InitDevice() {
	M[0] = 0;
	M[1] = 1;
	db o = 1;
	int sz = 1;
	do {
		o *= w;
		ll u = (ll)(o);
		if (!M.count(u))
			M[u] = ++sz;
	} while (o <= N * 2);
	for (auto it : M)
		len[it.se] = it.fi;
}

int Answer(ll S,ll T) {
	int a = S % N;
	int b = a + len[S / N];
	int c = T % N;
	int d = c + len[T / N];
	if (a <= c && d <= b)
		return 1;
	if (c <= a && b <= d)
		return 0;
	return 2;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 12544 KB Output is correct
2 Correct 8 ms 12544 KB Output is correct
3 Correct 9 ms 12544 KB Output is correct
4 Correct 9 ms 12544 KB Output is correct
5 Correct 10 ms 12544 KB Output is correct
6 Correct 8 ms 12544 KB Output is correct
7 Correct 9 ms 12416 KB Output is correct
8 Correct 9 ms 12544 KB Output is correct
9 Correct 9 ms 12544 KB Output is correct
10 Correct 8 ms 12544 KB Output is correct
11 Correct 8 ms 12544 KB Output is correct
12 Correct 8 ms 12544 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 171 ms 19400 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -