# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
585632 |
2022-06-29T06:53:14 Z |
zaneyu |
City (JOI17_city) |
C++14 |
|
366 ms |
51540 KB |
#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=25e4+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=25e4+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=ans[(S/maxn)]+si;
int ti=T%maxn,to=ans[(T/maxn)]+ti;
if(si<=ti and to<=so) return 1;
if(ti<=si and so<=to) return 0;
return 2;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
6560 KB |
Output is correct |
2 |
Correct |
3 ms |
6560 KB |
Output is correct |
3 |
Correct |
3 ms |
6548 KB |
Output is correct |
4 |
Correct |
3 ms |
6552 KB |
Output is correct |
5 |
Correct |
5 ms |
6556 KB |
Output is correct |
6 |
Correct |
3 ms |
6552 KB |
Output is correct |
7 |
Correct |
3 ms |
6560 KB |
Output is correct |
8 |
Correct |
3 ms |
6552 KB |
Output is correct |
9 |
Correct |
3 ms |
6552 KB |
Output is correct |
10 |
Correct |
3 ms |
6648 KB |
Output is correct |
11 |
Correct |
3 ms |
6632 KB |
Output is correct |
12 |
Correct |
3 ms |
6552 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
164 ms |
21936 KB |
Output is correct - L = 34000680 |
2 |
Correct |
157 ms |
21972 KB |
Output is correct - L = 34250685 |
3 |
Correct |
164 ms |
21980 KB |
Output is correct - L = 34000680 |
4 |
Correct |
155 ms |
21940 KB |
Output is correct - L = 34250685 |
5 |
Incorrect |
366 ms |
51540 KB |
Wrong Answer [6] |
6 |
Halted |
0 ms |
0 KB |
- |