#include "Encoder.h"
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld long double
#define pii pair<int,int>
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=5e5+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=998244353;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
int in[maxn];
int cnt=0;
vector<int> v[maxn];
void dfs(int u,int p){
in[u]=(cnt++);
for(int x:v[u]){
if(x==p) continue;
dfs(x,u);
}
int sz=cnt-in[u];
double cur=1.0,w=1.05;
int pw=0;
while((int)cur<sz) cur=cur*w,++pw;
cnt=in[u]+(int)cur;
Code(u,pw*maxn+in[u]);
}
void Encode(int n, int A[], int B[])
{
REP(i,n-1) v[A[i]].pb(B[i]),v[B[i]].pb(A[i]);
dfs(0,-1);
}
#include "Device.h"
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld long double
#define pii pair<int,int>
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=5e5+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=998244353;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
ld ans[maxn];
void InitDevice(){
ans[0]=1.0;
REP1(i,2050) ans[i]=ans[i-1]*1.05;
}
int Answer(long long S, long long T)
{
int si=S%maxn,so=(int)ans[(S/maxn)]+si;
int ti=T%maxn,to=(int)ans[(T/maxn)]+ti;
if(si<=ti and to<=so) return 1;
if(ti<=si and so<=to) return 0;
return 2;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
12448 KB |
Output is correct |
2 |
Correct |
6 ms |
12448 KB |
Output is correct |
3 |
Correct |
6 ms |
12456 KB |
Output is correct |
4 |
Correct |
6 ms |
12456 KB |
Output is correct |
5 |
Correct |
6 ms |
12500 KB |
Output is correct |
6 |
Correct |
6 ms |
12456 KB |
Output is correct |
7 |
Correct |
7 ms |
12564 KB |
Output is correct |
8 |
Correct |
7 ms |
12448 KB |
Output is correct |
9 |
Correct |
8 ms |
12456 KB |
Output is correct |
10 |
Correct |
6 ms |
12456 KB |
Output is correct |
11 |
Correct |
6 ms |
12512 KB |
Output is correct |
12 |
Correct |
6 ms |
12456 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
188 ms |
20848 KB |
Output is correct - L = 68000680 |
2 |
Correct |
214 ms |
20920 KB |
Output is correct - L = 68500685 |
3 |
Correct |
167 ms |
20868 KB |
Output is correct - L = 68000680 |
4 |
Correct |
168 ms |
20948 KB |
Output is correct - L = 68500685 |
5 |
Correct |
443 ms |
44024 KB |
Output is correct - L = 129501295 |
6 |
Correct |
478 ms |
57408 KB |
Output is correct - L = 130001300 |
7 |
Correct |
442 ms |
57556 KB |
Output is correct - L = 130001300 |
8 |
Correct |
470 ms |
57232 KB |
Output is correct - L = 131501315 |
9 |
Correct |
377 ms |
58296 KB |
Output is correct - L = 135001350 |
10 |
Correct |
386 ms |
58276 KB |
Output is correct - L = 136001360 |
11 |
Correct |
382 ms |
58288 KB |
Output is correct - L = 136001360 |
12 |
Correct |
350 ms |
58316 KB |
Output is correct - L = 136001360 |
13 |
Correct |
397 ms |
57904 KB |
Output is correct - L = 132501325 |
14 |
Correct |
415 ms |
57564 KB |
Output is correct - L = 130501305 |
15 |
Correct |
192 ms |
27768 KB |
Output is correct - L = 68000680 |
16 |
Correct |
192 ms |
27928 KB |
Output is correct - L = 68000680 |
17 |
Correct |
190 ms |
27912 KB |
Output is correct - L = 68000680 |
18 |
Correct |
401 ms |
57592 KB |
Output is correct - L = 135501355 |
19 |
Correct |
395 ms |
57536 KB |
Output is correct - L = 135501355 |
20 |
Correct |
428 ms |
57528 KB |
Output is correct - L = 135501355 |
21 |
Correct |
416 ms |
57496 KB |
Output is correct - L = 135001350 |
22 |
Correct |
444 ms |
57536 KB |
Output is correct - L = 135501355 |
23 |
Correct |
485 ms |
57476 KB |
Output is correct - L = 135501355 |
24 |
Correct |
404 ms |
57608 KB |
Output is correct - L = 135001350 |
25 |
Correct |
480 ms |
57460 KB |
Output is correct - L = 134501345 |
26 |
Correct |
559 ms |
57600 KB |
Output is correct - L = 134001340 |
27 |
Correct |
411 ms |
57588 KB |
Output is correct - L = 133001330 |