// 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 |
1 |
Incorrect |
2 ms |
1816 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
5684 KB |
Output is correct |
2 |
Incorrect |
33 ms |
5412 KB |
Wrong Answer [7] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1672 KB |
Output is correct |
2 |
Correct |
2 ms |
1812 KB |
Output is correct |
3 |
Correct |
2 ms |
1800 KB |
Output is correct |
4 |
Correct |
4 ms |
2884 KB |
Output is correct |
5 |
Correct |
4 ms |
2372 KB |
Output is correct |
6 |
Correct |
4 ms |
2608 KB |
Output is correct |
7 |
Correct |
4 ms |
2372 KB |
Output is correct |
8 |
Correct |
5 ms |
2500 KB |
Output is correct |
9 |
Correct |
16 ms |
5180 KB |
Output is correct |
10 |
Correct |
15 ms |
5328 KB |
Output is correct |
11 |
Correct |
16 ms |
5452 KB |
Output is correct |
12 |
Correct |
2 ms |
1672 KB |
Output is correct |
13 |
Correct |
2 ms |
1820 KB |
Output is correct |
14 |
Correct |
2 ms |
1672 KB |
Output is correct |
15 |
Correct |
2 ms |
1812 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
5540 KB |
Output is correct |
2 |
Correct |
32 ms |
5684 KB |
Output is correct |
3 |
Correct |
35 ms |
5824 KB |
Output is correct |
4 |
Incorrect |
19 ms |
4028 KB |
Wrong Answer [7] |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
5556 KB |
Output is correct |
2 |
Correct |
32 ms |
5548 KB |
Output is correct |
3 |
Correct |
31 ms |
5548 KB |
Output is correct |
4 |
Correct |
19 ms |
4032 KB |
Output is correct |
5 |
Incorrect |
19 ms |
4924 KB |
Wrong Answer [7] |
6 |
Halted |
0 ms |
0 KB |
- |