제출 #1170212

#제출 시각아이디문제언어결과실행 시간메모리
1170212TobCity (JOI17_city)C++20
98 / 100
244 ms30464 KiB
#include <bits/stdc++.h> #include "Encoder.h" #define all(x) x.begin(), x.end() #define pb push_back #define FIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0) using namespace std; typedef long long ll; typedef pair <ll, ll> pii; const int maxn = 25e4 + 7; int tim; vector <int> adj[maxn]; ll st[maxn], siz[maxn]; vector <ll> v; void dfs(int x, int p = -1) { st[x] = tim++; siz[x] = 1; for (int y : adj[x]) if (y != p) { dfs(y, x); siz[x] += siz[y]; } int pp = lower_bound(all(v), siz[x]) - v.begin(); siz[x] = v[pp]; tim = st[x] + siz[x]; Code(x, (st[x] << 9) + pp); } void Encode(int n, int a[], int b[]) { v = {1}; for (int i = 0; i <= 400; i++) v.pb((v[i]*21+19)/20); for (int i = 0; i < n-1; i++) adj[a[i]].pb(b[i]), adj[b[i]].pb(a[i]); dfs(0); }
#include <bits/stdc++.h> #include "Device.h" #define all(x) x.begin(), x.end() #define pb push_back #define FIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0) using namespace std; typedef long long ll; typedef pair <ll, ll> pii; vector <ll> v; void InitDevice() { v = {1}; for (int i = 0; i <= 400; i++) v.pb((v[i]*21+19)/20); } int Answer(ll S, ll T) { int o = 1; ll sta = (S >> 9), stb = (T >> 9); if (sta > stb) swap(S, T), swap(sta, stb), o = 0; ll siza = (S & (1 << 9)-1); if (sta+v[siza] <= stb) return 2; return o; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...