# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1080556 | kwongweng | City (JOI17_city) | C++17 | 324 ms | 56480 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |