Submission #130638

#TimeUsernameProblemLanguageResultExecution timeMemory
130638RezwanArefin01City (JOI17_city)C++17
8 / 100
201 ms24304 KiB
#include <bits/stdc++.h> #include "Encoder.h" using namespace std; const int N = 2e5 + 5; vector<int> a, adj[N]; int in[N], sz[N], idx; void build() { double r = pow(2, 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++, sz[u] = 1; for(int v : adj[u]) if(v - p) { dfs(v, u); sz[u] += sz[v]; } int opt = lower_bound(a.begin(), a.end(), sz[u]) - a.begin(); sz[u] = a[opt]; idx = in[u] + sz[u]; Code(u, ((long long)in[u] << 8) | opt); } 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...