This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// M
#include<bits/stdc++.h>
#include "Joi.h"
using namespace std;
static const int N = 10004, LG = 60;
static int n, ts, M[N], C[N];
static vector < int > Adj[N], Ch[N];
static void DFS(int v)
{
M[v] = 1;
for (int u : Adj[v])
if (!M[u])
Ch[v].push_back(u), DFS(u);
}
static void Build(int v)
{
for (int u : Ch[v])
Build(u);
C[v] = ts ++;
ts %= LG;
}
void Joi(int _n, int m, int A[], int B[], long long X, int T)
{
n = _n;
for (int i = 0; i < m; i ++)
Adj[A[i]].push_back(B[i]),
Adj[B[i]].push_back(A[i]);
for (int i = 0; i < n; i ++)
sort(Adj[i].begin(), Adj[i].end());
DFS(0);
Build(0);
for (int i = 0; i < n; i ++)
MessageBoard(i, (X >> C[i]) & 1LL);
}
// M
#include<bits/stdc++.h>
#include "Ioi.h"
using namespace std;
static const int N = 10004, LG = 60;
static int n, ts, M[N], C[N];
static vector < int > Adj[N], Ch[N];
static void DFS(int v)
{
M[v] = 1;
for (int u : Adj[v])
if (!M[u])
Ch[v].push_back(u), DFS(u);
}
static void Build(int v)
{
for (int u : Ch[v])
Build(u);
C[v] = ts ++;
ts %= LG;
}
static void Solve(int v, int mrk)
{
M[C[v]] = mrk;
for (int u : Adj[v])
if (M[C[u]] == -1)
Solve(u, Move(u)), Move(v);
}
long long Ioi(int _n, int m, int A[], int B[], int P, int V, int T)
{
n = _n;
for (int i = 0; i < m; i ++)
Adj[A[i]].push_back(B[i]),
Adj[B[i]].push_back(A[i]);
for (int i = 0; i < n; i ++)
sort(Adj[i].begin(), Adj[i].end());
DFS(0);
Build(0);
memset(M, -1, sizeof(M));
Solve(P, V);
long long X = 0;
for (int i = 0; i < LG; i ++)
if (M[i]) X |= 1LL << i;
return X;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |