# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
563913 | blue | City (JOI17_city) | C++17 | 287 ms | 37164 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 <vector>
#include <algorithm>
#include <iostream>
using namespace std;
namespace{
using vi = vector<int>;
using vvi = vector<vi>;
#define sz(x) int(x.size())
const int mx = 250'000;
using ll = long long;
using vll = vector<ll>;
int N;
vi edge[mx];
vi children[mx];
vll code(mx, 0);
void dfs(int u, int p)
{
int vct = 0;
for(int v : edge[u])
{
if(v == p) continue;
children[u].push_back(v);
vct++;
}
int vp = 1;
while((1<<vp) < vct)
vp++;
int ci = -1;
for(int v : children[u])
{
ci++;
code[v] = (code[u] << vp) + ci;
dfs(v, u);
}
}
}
void Encode(int N_, int A[], int B[])
{
N = N_;
for(int e = 0; e < N-1; e++)
{
edge[A[e]].push_back(B[e]);
edge[B[e]].push_back(A[e]);
}
code[0] = 1;
dfs(0, -1);
for(int i = 0; i < N; i++)
{
vi codelist;
ll z = code[i];
while(z > 0)
{
codelist.push_back(z%2);
z >>= 1;
}
// cerr << code[i] << ' ';
// cerr << '\n';
// for(int f = sz(codelist)-1; f >= 0; f--)
// cerr << codelist[f];
// cerr << ' ';
}
// cerr << '\n';
for(int i = 0; i < N; i++)
Code(i, code[i]);
}
#include "Device.h"
#include <vector>
#include <algorithm>
using namespace std;
namespace
{
using vi = vector<int>;
using vvi = vector<vi>;
#define sz(x) int(x.size())
}
void InitDevice()
{
;
}
int Answer(long long S, long long T)
{
vi sv, tv;
while(S != 0)
{
sv.push_back(S & 1);
S >>= 1;
}
while(T != 0)
{
tv.push_back(T & 1);
T >>= 1;
}
reverse(sv.begin(), sv.end());
reverse(tv.begin(), tv.end());
for(int i = 0; i < min(sz(sv), sz(tv)); i++)
{
if(sv[i] != tv[i]) return 2;
}
if(sz(sv) > sz(tv))
return 0;
else
return 1;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |