Submission #130650

#TimeUsernameProblemLanguageResultExecution timeMemory
130650RezwanArefin01City (JOI17_city)C++17
8 / 100
204 ms19184 KiB
#include <bits/stdc++.h> #include "Encoder.h" using namespace std; const int N = 2e5 + 5; vector<int> a, adj[N]; int in[N], idx; void build() { double r = pow(2.0, 20.0 / 256.0); a.push_back(1); while(a.size() < 256) { int x = a.back() * r; if(x == a.back()) ++x; a.push_back(x); } } void dfs(int u, int p) { in[u] = idx++; for(int v : adj[u]) if(v - p) dfs(v, u); int t = lower_bound(a.begin(), a.end(), idx - in[u]) - a.begin(); idx = in[u] + a[t];; Code(u, ((long long)in[u] << 8) | t); } void Encode(int n, int A[], int B[]) { build(); for(int i = 0; i < n - 1; ++i) { adj[A[i]].push_back(B[i]); adj[B[i]].push_back(A[i]); } dfs(0, -1); }
#include <bits/stdc++.h> #include "Device.h" using namespace std; vector<int> seq; void InitDevice() { double r = pow(2, 20.0 / 256.0); seq.push_back(1); while(seq.size() < 256) { int x = seq.back() * r; if(x == seq.back()) ++x; seq.push_back(x); } } int cnt = 0; int Answer(long long S, long long T) { int inu = S >> 8, szu = seq[S & 255]; int inv = T >> 8, szv = seq[T & 255]; if(inv <= inu && inu < inv + szv) return 0; if(inu <= inv && inv < inu + szu) return 1; return 2; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...