Submission #67509

#TimeUsernameProblemLanguageResultExecution timeMemory
67509realityCity (JOI17_city)C++17
100 / 100
539 ms88040 KiB
#include "Encoder.h" #include "bits/stdc++.h" using namespace std; #define fi first #define se second #define ll long long #define dbg(v) cerr<<#v<<" = "<<v<<'\n' #define vi vector<int> #define vl vector <ll> #define pii pair<int,int> #define vii vector < pii > #define mp make_pair #define db long double #define pb push_back #define all(s) s.begin(),s.end() template < class P , class Q > ostream& operator<<(ostream& stream, pair < P , Q > v){ stream << "(" << v.fi << ',' << v.se << ")"; return stream;} template < class T > ostream& operator<<(ostream& stream, const vector<T> v){ stream << "[ "; for (int i=0; i<(int)v.size(); i++) stream << v[i] << " "; stream << "]"; return stream;} template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;} template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;} static const int N = 1e6; static const db w = 1.05; static int len[N]; static int wh[N]; vi g[N + 69]; static int T = -1; void dfs(int node = 0,int prev = -1) { int beg = ++T; for (auto it : g[node]) if (it != prev) dfs(it,node); int cnt = lower_bound(len,len + 256,T - beg + 1) - len; T = beg + len[cnt] - 1; Code(node,1ll * cnt * N + beg); } void Encode(int NN, int A[], int B[]) { int n = NN; for (int i = 0;i + 1 < n;++i) { g[A[i]].pb(B[i]); g[B[i]].pb(A[i]); } len[0] = 1; for (int i = 1;i < 256;++i) len[i] = max(len[i - 1] + 1,(int)(w * len[i - 1])); dfs(); }
#include "Device.h" #include "bits/stdc++.h" using namespace std; #define fi first #define se second #define ll long long #define dbg(v) cerr<<#v<<" = "<<v<<'\n' #define vi vector<int> #define vl vector <ll> #define pii pair<int,int> #define vii vector < pii > #define mp make_pair #define db long double #define pb push_back #define all(s) s.begin(),s.end() template < class P , class Q > ostream& operator<<(ostream& stream, pair < P , Q > v){ stream << "(" << v.fi << ',' << v.se << ")"; return stream;} template < class T > ostream& operator<<(ostream& stream, const vector<T> v){ stream << "[ "; for (int i=0; i<(int)v.size(); i++) stream << v[i] << " "; stream << "]"; return stream;} template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;} template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;} static const int N = 1e6; static const db w = 1.05; static int len[N]; void InitDevice() { len[0] = 1; for (int i = 1;i < 256;++i) len[i] = max(len[i - 1] + 1,(int)(w * len[i - 1])); } int Answer(ll S,ll T) { int a = S % N; int b = a + len[(S / N)] - 1; int c = T % N; int d = c + len[(T / N)] - 1; if (c <= a && b <= d) return 0; if (a <= c && d <= b) return 1; return 2; }

Compilation message (stderr)

Encoder.cpp:27:12: warning: 'wh' defined but not used [-Wunused-variable]
 static int wh[N];
            ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...