Submission #1080556

#TimeUsernameProblemLanguageResultExecution timeMemory
1080556kwongwengCity (JOI17_city)C++17
30 / 100
324 ms56480 KiB
#include "Encoder.h" #include <bits/stdc++.h> using namespace std; typedef vector<int> vi; typedef long long ll; #define FOR(i,a,b) for(int i=a; i<b; i++) #define ROF(i,a,b) for(int i=a; i>=b; i--) #define pb push_back const ll N = 125000; vi g[N*2], p(N*2); vector<ll> sz(N*2), tin(N*2); int cnt = 0; void dfs(int u){ sz[u]=1; for (int v : g[u]){ if (p[u]==v) continue; p[v]=u; dfs(v); sz[u] += sz[v]; } } bool cond(int u, int v){ return sz[u]<sz[v]; } void dfs2(int u){ tin[u] = cnt++; for (int v : g[u]){ if (p[u]==v) continue; dfs2(v); } if (sz[u] >= N) Code(u,tin[u]*N); else Code(u,tin[u]*N + sz[u]); } void Encode(int n, int A[], int B[]) { FOR(i,0,n-1){ g[A[i]].pb(B[i]); g[B[i]].pb(A[i]); } dfs(0); FOR(i,0,n){ sort(g[i].begin(), g[i].end(), cond); } dfs2(0); }
#include "Device.h" #include <bits/stdc++.h> using namespace std; typedef vector<int> vi; typedef long long ll; #define FOR(i,a,b) for(int i=a; i<b; i++) #define ROF(i,a,b) for(int i=a; i>=b; i--) #define pb push_back const ll N = 125000; void InitDevice() { } int Answer(long long S, long long T) { //cout<<S/N<<" "<<S%N<<" "<<T/N<<" "<<T%N<<"\n"; if (S<T){ if (T/N < S/N + S%N || S%N == 0) return 1; return 2; } if (S/N < T/N + T%N || T%N == 0) return 0; return 2; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...