# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1080412 | thelegendary08 | City (JOI17_city) | C++14 | 113 ms | 32868 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>
#define pb push_back
#define ll long long
#define vi vector<ll>
#define vvi vector<vector<int>>
#define vll vector<long long int>
#define vvll vector<vector<long long int>>
#define pii pair<int, int>
#define vpii vector<pair<int, int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define mii map<int,int>
#define mll map<long long int, long long int>
#define mivi map<int,vector<int>>
#define f0r(i,n) for(int i=0;i<n;i++)
#define FOR(i,k,n) for(int i=k;i<n;i++)
using namespace std;
const int mxn = 250005;
vi order;
vi adj[mxn];
vb vis(mxn, 0);
vi sz(mxn, 0);
vi code(mxn, 0);
void dfs(int x){
if(vis[x])return;
int cur = 1;
vis[x] = 1;
order.pb(x);
for(auto u : adj[x]){
dfs(u);
}
}
int getsz(int x, int from){
int cur = 1;
for(auto u : adj[x]){
if(u != from){
cur += getsz(u, x);
}
}
sz[x] = cur;
return cur;
}
void Encode(int n, int a[], int b[])
{
f0r(i, n-1){
adj[a[i]].pb(b[i]);
adj[b[i]].pb(a[i]);
}
dfs(0);
f0r(i, n){
code[order[i]] = i;
}
getsz(0, -1);
for (int i = 0; i < n; ++i) {
int c = (1ll<<18) * sz[i] + code[i];
Code(i, c);
//cout<<i<<' '<<sz[i]<<' '<<code[i]<<'\n';
}
}
#include "Device.h"
#define ll long long
void InitDevice()
{
}
int Answer(long long S, long long T)
{
//cout<<S<<' '<<T<<'\n';
ll szs = S / 262144;
ll szt = T / 262144;
ll cs = S % 262144;
ll ct = T % 262144;
//cout<<cs<<' '<<ct<<' '<<szs<<' '<<szt<<'\n';
if(cs + szs > ct && ct > cs)return 1;
if(ct + szt > cs && cs > ct)return 0;
return 2;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |