// 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];
static void DFS(int v)
{
M[v] = 1;
for (int u : Adj[v])
if (!M[u])
DFS(u);
C[v] = ts; 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);
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], F[LG];
static vector < int > Adj[N];
static int now;
static set < pair < int , int > > ST;
static void DFS(int v)
{
M[v] = 1;
for (int u : Adj[v])
if (!M[u])
DFS(u);
C[v] = ts; ts ++;
ts %= LG;
}
static int MOVE(int v)
{
assert(now != v);
assert(ST.count({now, v}));
now = v;
return Move(v);
}
static void Solve(int v, int mrk)
{
F[C[v]] = mrk;
for (int u : Adj[v])
if (F[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 < m; i ++)
ST.insert({A[i], B[i]}),
ST.insert({B[i], A[i]});
now = P;
for (int i = 0; i < n; i ++)
sort(Adj[i].begin(), Adj[i].end());
DFS(0);
memset(F, -1, sizeof(F));
Solve(P, V);
long long X = 0;
for (int i = 0; i < LG; i ++)
if (F[i]) X |= 1LL << i;
return X;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
1532 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
44 ms |
6408 KB |
Output is correct |
2 |
Incorrect |
52 ms |
6412 KB |
Wrong Answer [7] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1536 KB |
Output is correct |
2 |
Correct |
2 ms |
1416 KB |
Output is correct |
3 |
Correct |
2 ms |
1540 KB |
Output is correct |
4 |
Correct |
5 ms |
1716 KB |
Output is correct |
5 |
Correct |
5 ms |
1844 KB |
Output is correct |
6 |
Correct |
5 ms |
1844 KB |
Output is correct |
7 |
Correct |
4 ms |
1844 KB |
Output is correct |
8 |
Correct |
4 ms |
1716 KB |
Output is correct |
9 |
Correct |
19 ms |
4652 KB |
Output is correct |
10 |
Correct |
18 ms |
4524 KB |
Output is correct |
11 |
Correct |
23 ms |
4656 KB |
Output is correct |
12 |
Correct |
2 ms |
1416 KB |
Output is correct |
13 |
Correct |
2 ms |
1456 KB |
Output is correct |
14 |
Correct |
2 ms |
1296 KB |
Output is correct |
15 |
Correct |
2 ms |
1536 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
50 ms |
6400 KB |
Output is correct |
2 |
Correct |
56 ms |
6180 KB |
Output is correct |
3 |
Correct |
51 ms |
6368 KB |
Output is correct |
4 |
Incorrect |
30 ms |
3884 KB |
Wrong Answer [7] |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
52 ms |
6416 KB |
Output is correct |
2 |
Correct |
57 ms |
6300 KB |
Output is correct |
3 |
Correct |
47 ms |
6172 KB |
Output is correct |
4 |
Correct |
24 ms |
4024 KB |
Output is correct |
5 |
Incorrect |
24 ms |
4420 KB |
Wrong Answer [7] |
6 |
Halted |
0 ms |
0 KB |
- |