#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)x.size()
#define beg(x) x.begin()
#define en(x) x.end()
#define all(x) beg(x), en(x)
#define resz resize
const int MOD = 1000000007; // 998244353
const ll INF = 1e18;
const int MX = 100001;
const ld PI = 4*atan((ld)1);
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
template<class A, class B> A operator+=(A& l, const B& r) { return l = l+r; }
template<class A, class B> A operator-=(A& l, const B& r) { return l = l-r; }
template<class A, class B> A operator*=(A& l, const B& r) { return l = l*r; }
template<class A, class B> A operator/=(A& l, const B& r) { return l = l/r; }
#include "Encoder.h"
static vi adj[1<<18];
static vi lens;
int dumb(int x) {
return lb(all(lens),x)-lens.begin();
}
int dfs(int x, int y, int st) {
int ST = st+1;
trav(i,adj[x]) if (i != y) ST = dfs(i,x,ST);
int d = dumb(ST-st); Code(x,((ll)st<<8)+d);
return st+lens[d];
}
void Encode(int N, int A[], int B[]) {
lens.pb(1);
FOR(i,1,256) {
int t = 1.05*lens.back();
if (t == lens.back()) t ++;
lens.pb(t);
}
F0R(i,N-1) adj[A[i]].pb(B[i]), adj[B[i]].pb(A[i]);
dfs(0,-1,0);
}
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)x.size()
#define beg(x) x.begin()
#define en(x) x.end()
#define all(x) beg(x), en(x)
#define resz resize
const int MOD = 1000000007; // 998244353
const ll INF = 1e18;
const int MX = 100001;
const ld PI = 4*atan((ld)1);
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
template<class A, class B> A operator+=(A& l, const B& r) { return l = l+r; }
template<class A, class B> A operator-=(A& l, const B& r) { return l = l-r; }
template<class A, class B> A operator*=(A& l, const B& r) { return l = l*r; }
template<class A, class B> A operator/=(A& l, const B& r) { return l = l/r; }
#include "Device.h"
static vi lens;
void InitDevice() {
lens.pb(1);
FOR(i,1,256) {
int t = 1.05*lens.back();
if (t == lens.back()) t ++;
lens.pb(t);
}
}
pi decode(ll x) {
pi a = {x>>8,lens[x%(1<<8)]};
a.s += a.f;
return a;
}
bool contain(pi a, pi b) {
return a.f <= b.f && b.s <= a.s;
}
int Answer(long long S, long long T) {
pi X = decode(S), Y = decode(T);
if (contain(X,Y)) return 1;
if (contain(Y,X)) return 0;
return 2;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
13056 KB |
Output is correct |
2 |
Correct |
10 ms |
13056 KB |
Output is correct |
3 |
Correct |
9 ms |
13056 KB |
Output is correct |
4 |
Correct |
9 ms |
13056 KB |
Output is correct |
5 |
Correct |
9 ms |
13056 KB |
Output is correct |
6 |
Correct |
9 ms |
13056 KB |
Output is correct |
7 |
Correct |
8 ms |
13056 KB |
Output is correct |
8 |
Correct |
15 ms |
13056 KB |
Output is correct |
9 |
Correct |
9 ms |
13056 KB |
Output is correct |
10 |
Correct |
9 ms |
13056 KB |
Output is correct |
11 |
Correct |
9 ms |
13056 KB |
Output is correct |
12 |
Correct |
10 ms |
13056 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
166 ms |
20016 KB |
Output is correct - L = 190976 |
2 |
Correct |
164 ms |
20096 KB |
Output is correct - L = 200704 |
3 |
Correct |
166 ms |
19992 KB |
Output is correct - L = 184832 |
4 |
Correct |
168 ms |
19952 KB |
Output is correct - L = 185600 |
5 |
Correct |
532 ms |
51840 KB |
Output is correct - L = 76660480 |
6 |
Correct |
511 ms |
51952 KB |
Output is correct - L = 77620992 |
7 |
Correct |
501 ms |
51888 KB |
Output is correct - L = 78295808 |
8 |
Correct |
513 ms |
51360 KB |
Output is correct - L = 85130240 |
9 |
Correct |
472 ms |
53160 KB |
Output is correct - L = 127444992 |
10 |
Correct |
412 ms |
53296 KB |
Output is correct - L = 126135808 |
11 |
Correct |
413 ms |
53464 KB |
Output is correct - L = 145971200 |
12 |
Correct |
422 ms |
53176 KB |
Output is correct - L = 132401920 |
13 |
Correct |
476 ms |
52704 KB |
Output is correct - L = 102124544 |
14 |
Correct |
513 ms |
52216 KB |
Output is correct - L = 83328512 |
15 |
Correct |
166 ms |
20024 KB |
Output is correct - L = 188416 |
16 |
Correct |
169 ms |
20008 KB |
Output is correct - L = 191232 |
17 |
Correct |
164 ms |
19984 KB |
Output is correct - L = 184064 |
18 |
Correct |
498 ms |
52328 KB |
Output is correct - L = 139020800 |
19 |
Correct |
502 ms |
52488 KB |
Output is correct - L = 63999744 |
20 |
Correct |
532 ms |
52208 KB |
Output is correct - L = 63999744 |
21 |
Correct |
473 ms |
52408 KB |
Output is correct - L = 132401664 |
22 |
Correct |
493 ms |
52272 KB |
Output is correct - L = 64462848 |
23 |
Correct |
467 ms |
52176 KB |
Output is correct - L = 64635648 |
24 |
Correct |
473 ms |
51888 KB |
Output is correct - L = 65628928 |
25 |
Correct |
496 ms |
52008 KB |
Output is correct - L = 65917696 |
26 |
Correct |
510 ms |
52112 KB |
Output is correct - L = 66733312 |
27 |
Correct |
525 ms |
51808 KB |
Output is correct - L = 66952448 |