# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1057478 | Piokemon | City (JOI17_city) | C++17 | 100 ms | 27808 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;
constexpr int N = 25e4;
vector<int> graf[N+9];
int pre[N+9];
int post[N+9];
int tajm=1;
int n;
void dfs(int v, int par){
pre[v]=tajm++;
for (int x:graf[v]){
if (x!=par)dfs(x,v);
}
int rozn=tajm-pre[v];
int temp=1;
while(temp<rozn)temp*=2;
tajm=pre[v]+temp;
post[v]=tajm;
}
void Encode(int n_, int A[], int B[]){
n=n_;
for (int i = 1; i < n; ++i) {
graf[A[i-1]].push_back(B[i-1]);
graf[B[i-1]].push_back(A[i-1]);
}
dfs(0,-1);
int stala=60;
for (int x=0;x<n;x++){
//cerr << pre[x] << ' ' << post[x] << '\n';
Code(x,stala*pre[x]+__lg(post[x]-pre[x]));
}
}
#include "Device.h"
#include <bits/stdc++.h>
using namespace std;
constexpr int stala = 60;
void InitDevice(){
//uwu
}
int Answer(long long S, long long T){
int pres,is,pret,it;
pres=S/stala; is=S%stala;
pret=T/stala; it=T%stala;
int posts,postt;
posts=pres+(1<<is);
postt=pret+(1<<it);
if (pres<=pret && postt<=posts)return 1;
if (pret<=pres && posts<=postt)return 0;
return 2;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |