Submission #699568

#TimeUsernameProblemLanguageResultExecution timeMemory
699568uroskCity (JOI17_city)C++14
100 / 100
395 ms61544 KiB
#include "Encoder.h" #include "bits/stdc++.h" //#include <ext/pb_ds/tree_policy.hpp> //#include <ext/pb_ds/assoc_container.hpp> #define ld double #define ll int #define llinf 100000000000000000LL // 10^17 #define pb push_back #define popb pop_back #define fi first #define sc second #define endl '\n' #define pll pair<ll,ll> #define pld pair<ld,ld> #define sz(a) (ll)(a.size()) #define all(a) a.begin(),a.end() #define ceri(a,l,r) {cerr<<#a<<": ";for(ll i_ = l;i_<=r;i_++) cerr<<a[i_]<< " ";cerr<<endl;} #define cer(a) {cerr<<#a<<": ";for(ll x_ : a) cerr<<x_<< " ";cerr<<endl;} #define daj_mi_malo_vremena ios_base::sync_with_stdio(false);cerr.tie(0);cout.tie(0);cin.tie(0); using namespace std; #define maxn 700005 ll n; vector<ll> g[maxn]; ll in[maxn],ti = 0; void dfs(ll u,ll p){ in[u] = ++ti; for(ll s : g[u]) if(s^p) dfs(s,u); double cur = 1.0,w = 1.05; ll ans = 0; while((ll)cur<ti-in[u]) cur*=w,ans++; ti = in[u] + (ll)(cur); Code(u,maxn*ans+in[u]); } void Encode(int N, int A[], int B[]) { n = N; for(ll i = 0;i<n-1;i++){ ll x = A[i],y = B[i]; g[x].pb(y); g[y].pb(x); } dfs(0,0); }
#include "Device.h" #include "bits/stdc++.h" //#include <ext/pb_ds/tree_policy.hpp> //#include <ext/pb_ds/assoc_container.hpp> #define ld double #define ll long long #define llinf 100000000000000000LL // 10^17 #define pb push_back #define popb pop_back #define fi first #define sc second #define endl '\n' #define pll pair<ll,ll> #define pld pair<ld,ld> #define sz(a) (ll)(a.size()) #define all(a) a.begin(),a.end() #define ceri(a,l,r) {cerr<<#a<<": ";for(ll i_ = l;i_<=r;i_++) cerr<<a[i_]<< " ";cerr<<endl;} #define cer(a) {cerr<<#a<<": ";for(ll x_ : a) cerr<<x_<< " ";cerr<<endl;} #define daj_mi_malo_vremena ios_base::sync_with_stdio(false);cerr.tie(0);cout.tie(0);cin.tie(0); using namespace std; #define maxx 1005 #define maxn 700005 ll len[maxx]; void InitDevice() { double cur = 1.0,w =1.05; len[0] = cur; for(ll i = 1;i<maxx;i++){ cur*=w; len[i] = (ll)(cur); } } int Answer(ll u,ll v) { ll inu = u%maxn,inv = v%maxn; ll outu = inu + len[u/maxn],outv = inv + len[v/maxn]; if(inv>=inu&&outu>=outv) return 1; if(inv<=inu&&outu<=outv) return 0; return 2; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...