Submission #996883

#TimeUsernameProblemLanguageResultExecution timeMemory
996883AdamGSCity (JOI17_city)C++17
8 / 100
245 ms39908 KiB
#include "Encoder.h" #include<bits/stdc++.h> using namespace std; typedef long long ll; #define rep(a, b) for(int a = 0; a < (b); ++a) #define st first #define nd second #define pb push_back #define all(a) a.begin(), a.end() const ll K=1096736; const int LIM=25e4+7; vector<int>V[LIM]; ll pre[LIM], lpre; ll rnd(ll x) { ll po=0, ko=1000000000; while(po<ko) { ll sr=(po+ko)/2; if(sr*sr<x) po=sr+1; else ko=sr; } return po; } void DFS(int x, int o) { pre[x]=lpre; ++lpre; for(auto i : V[x]) if(i!=o) DFS(i, x); ll z=lpre-pre[x]; lpre=pre[x]+rnd(z)*rnd(z); Code(x, pre[x]+K*rnd(z)); } 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, 0); }
#include "Device.h" #include<bits/stdc++.h> typedef long long ll; #define rep(a, b) for(int a = 0; a < (b); ++a) #define st first #define nd second #define pb push_back #define all(a) a.begin(), a.end() const ll K=1096736; void InitDevice() {} bool oc(ll x, ll y) { ll a=x%K, b=y%K, c=x/K; return a<=b && b<a+c*c; } int Answer(ll S, ll T) { if(oc(S, T)) return 1; if(oc(T, S)) return 0; return 2; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...