#include "Joi.h"
#include <bits/stdc++.h>
#define maxn 10005
#define f first
#define s second
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
static int idx[maxn], pai[maxn], deep[maxn], cnt, maior;
static vector<int> grafo[maxn], tree[maxn];
void dfs(int x)
{
idx[x] = cnt++;
maior = max(maior, deep[x] + 1);
for(auto v: grafo[x])
{
if(idx[v] != -1) continue;
pai[v] = x;
deep[v] = deep[x] + 1;
tree[x].push_back(v);
tree[v].push_back(x);
dfs(v);
}
}
void Joi(int N, int M, int A[], int B[], ll X, int T)
{
memset(idx, -1, sizeof idx);
for(int i = 0; i < M; i++)
{
grafo[A[i]].push_back(B[i]);
grafo[B[i]].push_back(A[i]);
}
dfs(0);
for(int i = 0; i < N; i++)
{
int id = (idx[i] % 60);
if(X & (1LL<<id)) MessageBoard(i, 1);
else MessageBoard(i, 0);
}
}
#include "Ioi.h"
#include <bits/stdc++.h>
#define maxn 10005
#define f first
#define s second
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
static int idx2[maxn], pai2[maxn], deep2[maxn], cnt2, maior2, dp[maxn];
static int opt[maxn];
static vector<int> grafo2[maxn], tree2[maxn];
static ll ans = 0;
static set<int> usados;
void dfs2(int x)
{
idx2[x] = cnt2++;
maior2 = max(maior2, deep2[x] + 1);
dp[x] = 0;
for(auto v: grafo2[x])
{
if(idx2[v] != -1) continue;
pai2[v] = x;
deep2[v] = deep2[x] + 1;
tree2[x].push_back(v);
tree2[v].push_back(x);
dfs2(v);
if(dp[v] + 1 > dp[x]) dp[x] = dp[v] + 1, opt[x] = v;
}
}
ll Ioi(int N, int M, int A[], int B[], int P, int V, int T)
{
memset(idx2, -1, sizeof idx2);
for(int i = 0; i < M; i++)
{
grafo2[A[i]].push_back(B[i]);
grafo2[B[i]].push_back(A[i]);
}
dfs2(0);
for(int i = 0; i < N; i++) deep2[i] = idx2[i]%60;
usados.insert(deep2[P] % 60);
if(V) ans += (1LL<< (deep2[P]%60) );
while(P != 0 and usados.size() < 60)
{
ll val = Move(pai2[P]), aux = deep2[pai2[P]]%60;
if(val && !usados.count(aux)) ans += (1LL<< (aux) );
usados.insert(aux);
P = pai2[P];
}
if(usados.size() >= 60) return ans;
while(usados.size() < 60 and opt[P])
{
ll val = Move(opt[P]), aux = deep2[opt[P]]%60;
if(val && !usados.count(aux)) ans += (1LL<< (aux) );
usados.insert(aux);
P = opt[P];
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
1892 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
35 ms |
5812 KB |
Output is correct |
2 |
Correct |
36 ms |
6152 KB |
Output is correct |
3 |
Correct |
37 ms |
6668 KB |
Output is correct |
4 |
Incorrect |
24 ms |
6832 KB |
Wrong Answer [7] |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
6832 KB |
Output is correct |
2 |
Correct |
5 ms |
6832 KB |
Output is correct |
3 |
Correct |
6 ms |
6832 KB |
Output is correct |
4 |
Correct |
7 ms |
6832 KB |
Output is correct |
5 |
Correct |
7 ms |
6832 KB |
Output is correct |
6 |
Correct |
7 ms |
6832 KB |
Output is correct |
7 |
Correct |
7 ms |
6832 KB |
Output is correct |
8 |
Correct |
8 ms |
6832 KB |
Output is correct |
9 |
Correct |
22 ms |
7212 KB |
Output is correct |
10 |
Correct |
33 ms |
7468 KB |
Output is correct |
11 |
Correct |
28 ms |
7656 KB |
Output is correct |
12 |
Correct |
6 ms |
7800 KB |
Output is correct |
13 |
Correct |
5 ms |
7800 KB |
Output is correct |
14 |
Correct |
7 ms |
7800 KB |
Output is correct |
15 |
Correct |
6 ms |
7800 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
7924 KB |
Output is correct |
2 |
Partially correct |
40 ms |
8180 KB |
Partially correct |
3 |
Partially correct |
48 ms |
8692 KB |
Partially correct |
4 |
Incorrect |
32 ms |
8920 KB |
Wrong Answer [7] |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
35 ms |
8940 KB |
Output is correct |
2 |
Correct |
41 ms |
9212 KB |
Output is correct |
3 |
Incorrect |
37 ms |
9596 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |