#include<bits/stdc++.h>
#include "Joi.h"
#define pb push_back
using namespace std;
const int MXN = 12345;
vector < int > Adj[MXN];
void Joi(int N, int M, int A[], int B[], long long X, int T)
{
for (int i = 0; i < M; i++)
Adj[A[i]].pb(B[i]), Adj[B[i]].pb(A[i]);
vector < int > D(N, -1);
vector < int > P(N, -1);
vector < int > qu(N, 0);
int l = 0, r = 0;
qu[r ++] = 0; D[0] = 0;
bool OK = 0;
while (r - l)
{
int v = qu[l ++];
if (D[v] == 59)
OK = 1;
for (int &u : Adj[v])
if (D[u] == -1)
D[u] = (D[v] + 1) % 60, P[u] = v, qu[r ++] = u;
}
if (OK)
{
for (int i = 0; i < N; i++)
MessageBoard(i, (X >> D[i]) & 1LL);
return ;
}
vector < int > F(N, -1);
vector < int > rev(N, -1);
for (int i = 0; i < N; i++)
rev[qu[i]] = i;
for (int i = 0; i < 60; i++)
MessageBoard(qu[i], (X >> i) & 1LL), F[qu[i]] = i;
for (int i = 60; i < N; i++)
{
int v = qu[i];
vector < int > Mark(60, 0);
for (int p = P[v]; p >= 0; p = P[p])
Mark[F[p]] = 1;
F[v] = 59;
while (Mark[F[v]])
F[v] --;
MessageBoard(v, (X >> F[v]) & 1LL);
}
return ;
}
#include<bits/stdc++.h>
#include "Ioi.h"
#define pb push_back
using namespace std;
const int MXN = 12345;
bool toSee[MXN], seen[MXN];
vector < int > vec, Adj[MXN];
void DFS(int v)
{
seen[v] = 1;
for (int &u : Adj[v])
if (!seen[u] && toSee[u])
{
vec.pb(u);
DFS(u);
vec.pb(v);
}
}
long long Ioi(int N, int M, int A[], int B[], int ST, int VL, int T)
{
for (int i = 0; i < M; i++)
Adj[A[i]].pb(B[i]), Adj[B[i]].pb(A[i]);
vector < int > D(N, -1);
vector < int > qu(N, 0);
vector < int > P(N, -1);
int l = 0, r = 0;
qu[r ++] = 0; D[0] = 0;
bool OK = 0;
while (r - l)
{
int v = qu[l ++];
if (D[v] % 60 == 59)
OK = 1;
for (int &u : Adj[v])
if (D[u] == -1)
D[u] = D[v] + 1, P[u] = v, qu[r ++] = u;
}
if (OK)
{
if (D[ST] >= 59)
{
long long X = 0;
for (int i = 0; i < 60; i++)
{
X |= (1LL * VL) << (D[ST] % 60);
if (i < 59)
ST = P[ST], VL = Move(ST);
}
return (X);
}
int start = -1;
for (int i = 0; i < N; i++)
if (D[i] == 59)
start = i;
assert(start != -1);
vector < int > ids(60, -1);
for (int i = 59; i >= 0; i--)
ids[i] = start, start = P[start];
long long X = 0;
while (ST != 0)
ST = P[ST], VL = Move(ST);
for (int i = 0; i < 60; i++)
{
X |= (1LL * VL) << (D[ST] % 60);
if (i + 1 < 60)
ST = ids[i + 1], VL = Move(ST);
}
return (X);
}
vector < int > F(N, -1);
vector < int > rev(N, -1);
for (int i = 0; i < N; i++)
rev[qu[i]] = i;
for (int i = 0; i < 60; i++)
F[qu[i]] = i;
for (int i = 60; i < N; i++)
{
int v = qu[i];
vector < int > Mark(60, 0);
for (int p = P[v]; p >= 0; p = P[p])
Mark[F[p]] = 1;
F[v] = 59;
while (Mark[F[v]])
F[v] --;
}
long long X = 0;
for (int i = 0; i < 60; i++)
toSee[qu[i]] = 1;
while (ST != 0)
{
X |= (1LL * VL) << (F[ST]);
//toSee[qu[F[ST]]] = 0;
ST = P[ST]; VL = Move(ST);
}
X |= VL;
DFS(0);
for (int v : vec)
{
ST = v; VL = Move(ST);
X |= (1LL * VL) << (F[ST]);
}
return (X);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1444 KB |
Output is correct |
2 |
Correct |
5 ms |
1416 KB |
Output is correct |
3 |
Correct |
4 ms |
1420 KB |
Output is correct |
4 |
Correct |
4 ms |
1408 KB |
Output is correct |
5 |
Correct |
4 ms |
1408 KB |
Output is correct |
6 |
Correct |
4 ms |
1328 KB |
Output is correct |
7 |
Correct |
5 ms |
1420 KB |
Output is correct |
8 |
Correct |
4 ms |
1324 KB |
Output is correct |
9 |
Correct |
4 ms |
1320 KB |
Output is correct |
10 |
Correct |
4 ms |
1328 KB |
Output is correct |
11 |
Correct |
7 ms |
1592 KB |
Output is correct |
12 |
Correct |
4 ms |
1456 KB |
Output is correct |
13 |
Correct |
4 ms |
1448 KB |
Output is correct |
14 |
Correct |
4 ms |
1320 KB |
Output is correct |
15 |
Correct |
4 ms |
1284 KB |
Output is correct |
16 |
Correct |
4 ms |
1420 KB |
Output is correct |
17 |
Correct |
5 ms |
1412 KB |
Output is correct |
18 |
Correct |
4 ms |
1420 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
3864 KB |
Output is correct |
2 |
Correct |
27 ms |
3908 KB |
Output is correct |
3 |
Correct |
27 ms |
3868 KB |
Output is correct |
4 |
Correct |
18 ms |
3068 KB |
Output is correct |
5 |
Correct |
17 ms |
3008 KB |
Output is correct |
6 |
Correct |
17 ms |
2888 KB |
Output is correct |
7 |
Correct |
17 ms |
3016 KB |
Output is correct |
8 |
Correct |
17 ms |
2888 KB |
Output is correct |
9 |
Correct |
17 ms |
2888 KB |
Output is correct |
10 |
Correct |
17 ms |
3240 KB |
Output is correct |
11 |
Correct |
18 ms |
3200 KB |
Output is correct |
12 |
Correct |
18 ms |
2968 KB |
Output is correct |
13 |
Correct |
18 ms |
2944 KB |
Output is correct |
14 |
Correct |
17 ms |
2952 KB |
Output is correct |
15 |
Correct |
19 ms |
3164 KB |
Output is correct |
16 |
Correct |
19 ms |
3204 KB |
Output is correct |
17 |
Correct |
19 ms |
3132 KB |
Output is correct |
18 |
Correct |
19 ms |
3068 KB |
Output is correct |
19 |
Correct |
20 ms |
3132 KB |
Output is correct |
20 |
Correct |
14 ms |
2888 KB |
Output is correct |
21 |
Correct |
11 ms |
3008 KB |
Output is correct |
22 |
Correct |
17 ms |
3008 KB |
Output is correct |
23 |
Correct |
17 ms |
2880 KB |
Output is correct |
24 |
Correct |
17 ms |
2880 KB |
Output is correct |
25 |
Correct |
17 ms |
2888 KB |
Output is correct |
26 |
Correct |
18 ms |
2880 KB |
Output is correct |
27 |
Correct |
18 ms |
2960 KB |
Output is correct |
28 |
Correct |
16 ms |
2900 KB |
Output is correct |
29 |
Correct |
15 ms |
2992 KB |
Output is correct |
30 |
Correct |
15 ms |
2880 KB |
Output is correct |
31 |
Correct |
5 ms |
1328 KB |
Output is correct |
32 |
Correct |
4 ms |
1280 KB |
Output is correct |
33 |
Correct |
4 ms |
1412 KB |
Output is correct |
34 |
Correct |
5 ms |
1456 KB |
Output is correct |
35 |
Correct |
4 ms |
1280 KB |
Output is correct |
36 |
Correct |
4 ms |
1408 KB |
Output is correct |
37 |
Correct |
4 ms |
1288 KB |
Output is correct |
38 |
Correct |
4 ms |
1416 KB |
Output is correct |
39 |
Correct |
4 ms |
1492 KB |
Output is correct |
40 |
Correct |
4 ms |
1416 KB |
Output is correct |
41 |
Correct |
4 ms |
1416 KB |
Output is correct |
42 |
Correct |
5 ms |
1288 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1280 KB |
Output is correct |
2 |
Correct |
4 ms |
1408 KB |
Output is correct |
3 |
Correct |
4 ms |
1408 KB |
Output is correct |
4 |
Correct |
5 ms |
1564 KB |
Output is correct |
5 |
Correct |
6 ms |
1700 KB |
Output is correct |
6 |
Correct |
6 ms |
1624 KB |
Output is correct |
7 |
Correct |
6 ms |
1628 KB |
Output is correct |
8 |
Correct |
6 ms |
1692 KB |
Output is correct |
9 |
Correct |
13 ms |
2888 KB |
Output is correct |
10 |
Correct |
13 ms |
3036 KB |
Output is correct |
11 |
Correct |
13 ms |
2904 KB |
Output is correct |
12 |
Correct |
4 ms |
1332 KB |
Output is correct |
13 |
Correct |
4 ms |
1280 KB |
Output is correct |
14 |
Correct |
4 ms |
1408 KB |
Output is correct |
15 |
Correct |
4 ms |
1416 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
27 ms |
3900 KB |
Partially correct |
2 |
Partially correct |
28 ms |
3864 KB |
Partially correct |
3 |
Partially correct |
27 ms |
3856 KB |
Partially correct |
4 |
Partially correct |
20 ms |
3076 KB |
Partially correct |
5 |
Correct |
18 ms |
3120 KB |
Output is correct |
6 |
Correct |
18 ms |
3140 KB |
Output is correct |
7 |
Correct |
15 ms |
3008 KB |
Output is correct |
8 |
Correct |
15 ms |
3060 KB |
Output is correct |
9 |
Correct |
16 ms |
2896 KB |
Output is correct |
10 |
Correct |
18 ms |
3204 KB |
Output is correct |
11 |
Correct |
19 ms |
3216 KB |
Output is correct |
12 |
Partially correct |
19 ms |
2824 KB |
Partially correct |
13 |
Partially correct |
19 ms |
2968 KB |
Partially correct |
14 |
Partially correct |
19 ms |
3156 KB |
Partially correct |
15 |
Partially correct |
18 ms |
3152 KB |
Partially correct |
16 |
Partially correct |
18 ms |
3200 KB |
Partially correct |
17 |
Partially correct |
19 ms |
3076 KB |
Partially correct |
18 |
Partially correct |
19 ms |
3124 KB |
Partially correct |
19 |
Partially correct |
19 ms |
3308 KB |
Partially correct |
20 |
Correct |
13 ms |
3008 KB |
Output is correct |
21 |
Correct |
13 ms |
3016 KB |
Output is correct |
22 |
Correct |
17 ms |
2888 KB |
Output is correct |
23 |
Correct |
18 ms |
3028 KB |
Output is correct |
24 |
Correct |
17 ms |
2972 KB |
Output is correct |
25 |
Correct |
17 ms |
2880 KB |
Output is correct |
26 |
Correct |
17 ms |
3008 KB |
Output is correct |
27 |
Correct |
18 ms |
3008 KB |
Output is correct |
28 |
Correct |
16 ms |
2880 KB |
Output is correct |
29 |
Correct |
15 ms |
2956 KB |
Output is correct |
30 |
Correct |
15 ms |
2880 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
27 ms |
3856 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |