#include <bits/stdc++.h>
#include "Joi.h"
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
static vector <int> V[10101], T[10101], X;
static vector <pii> E[10101];
static int S[10101], C[10101];
static bool vis[10101];
static int cnt;
static void dfs1(int p, int r)
{
vis[p] = 1;
for(int &t: V[p]){
if(!vis[t]){
T[p].push_back(t);
dfs1(t, p);
}
}
}
static void dfs2(int p, int r)
{
C[p] = cnt;
if(++cnt == 60) return;
for(int &t: T[p]){
E[0].emplace_back(t, p);
X.push_back(t);
dfs2(t, p);
if(cnt == 60) return;
}
}
static void dfs3(int p, int r)
{
if(E[p].empty()){
int i;
E[p] = E[r];
for(pii &e: E[p]){
S[e.first] = 0; S[e.second] = 0;
}
for(pii &e: E[p]){
S[e.first] ++; S[e.second] ++;
}
for(i=0; i<E[p].size(); i++){
if(S[E[p][i].first] == 1 && E[p][i].first != r) break;
if(S[E[p][i].second] == 1 && E[p][i].second != r) break;
}
if(S[E[p][i].first] == 1) C[p] = C[E[p][i].first];
else C[p] = C[E[p][i].second];
swap(E[p][i], E[p].back()); E[p].pop_back();
E[p].emplace_back(p, r);
}
for(int &t: T[p]){
dfs3(t, p);
}
}
void Joi(int n, int m, int A[], int B[], ll x, int t)
{
int i;
for(i=0; i<m; i++){
V[A[i]].push_back(B[i]);
V[B[i]].push_back(A[i]);
}
dfs1(0, 0);
dfs2(0, 0);
for(int &x: X){
E[x] = E[0];
}
dfs3(0, 0);
for(i=0; i<n; i++){
MessageBoard(i, x & (1ll << C[i])? 1 : 0);
}
}
#include <bits/stdc++.h>
#include "Ioi.h"
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
static vector <int> V[10101], T[10101], X;
static vector <pii> E[10101];
static int S[10101], C[10101];
static bool chk[10101], vis[10101];
static int cnt;
static ll ans;
static void move(int p)
{
ll v = Move(p);
if(!chk[p]){
chk[p] = 1;
ans += v << C[p];
}
}
static void dfs1(int p, int r)
{
vis[p] = 1;
for(int &t: V[p]){
if(!vis[t]){
T[p].push_back(t);
dfs1(t, p);
}
}
}
static void dfs2(int p, int r)
{
C[p] = cnt++;
if(cnt == 60) return;
for(int &t: T[p]){
E[0].emplace_back(t, p);
X.push_back(t);
dfs2(t, p);
if(cnt == 60) return;
}
}
static void dfs3(int p, int r)
{
if(E[p].empty()){
int i;
E[p] = E[r];
for(pii &e: E[p]){
S[e.first] = 0; S[e.second] = 0;
}
for(pii &e: E[p]){
S[e.first] ++; S[e.second] ++;
}
for(i=0; i<E[p].size(); i++){
if(S[E[p][i].first] == 1 && E[p][i].first != r) break;
if(S[E[p][i].second] == 1 && E[p][i].second != r) break;
}
if(S[E[p][i].first] == 1) C[p] = C[E[p][i].first];
else C[p] = C[E[p][i].second];
swap(E[p][i], E[p].back()); E[p].pop_back();
E[p].emplace_back(p, r);
}
for(int &t: T[p]){
dfs3(t, p);
}
}
static void dfs4(int p, int r)
{
for(int &t: T[p]){
if(t != r){
move(t);
dfs4(t, p);
move(p);
}
}
}
ll Ioi(int n, int m, int A[], int B[], int p, int v, int t)
{
int i;
for(i=0; i<m; i++){
V[A[i]].push_back(B[i]);
V[B[i]].push_back(A[i]);
}
dfs1(0, 0);
dfs2(0, 0);
for(int &x: X){
E[x] = E[0];
}
dfs3(0, 0);
for(i=0; i<n; i++){
T[i].clear();
}
for(pii &e: E[p]){
T[e.first].push_back(e.second);
T[e.second].push_back(e.first);
}
dfs4(p, p);
return ans;
}
Compilation message
Joi.cpp: In function 'void dfs3(int, int)':
Joi.cpp:55:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(i=0; i<E[p].size(); i++){
~^~~~~~~~~~~~
Ioi.cpp: In function 'void dfs3(int, int)':
Ioi.cpp:65:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(i=0; i<E[p].size(); i++){
~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
2400 KB |
Output is correct |
2 |
Correct |
5 ms |
2428 KB |
Output is correct |
3 |
Correct |
6 ms |
2792 KB |
Output is correct |
4 |
Correct |
5 ms |
2380 KB |
Output is correct |
5 |
Correct |
5 ms |
2420 KB |
Output is correct |
6 |
Correct |
6 ms |
2392 KB |
Output is correct |
7 |
Correct |
6 ms |
2656 KB |
Output is correct |
8 |
Correct |
6 ms |
2564 KB |
Output is correct |
9 |
Correct |
6 ms |
2772 KB |
Output is correct |
10 |
Correct |
6 ms |
2424 KB |
Output is correct |
11 |
Correct |
9 ms |
2596 KB |
Output is correct |
12 |
Correct |
5 ms |
2296 KB |
Output is correct |
13 |
Correct |
6 ms |
2560 KB |
Output is correct |
14 |
Correct |
6 ms |
2296 KB |
Output is correct |
15 |
Correct |
6 ms |
2560 KB |
Output is correct |
16 |
Correct |
6 ms |
2552 KB |
Output is correct |
17 |
Correct |
7 ms |
2732 KB |
Output is correct |
18 |
Correct |
6 ms |
2784 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
60 ms |
15040 KB |
Output is correct |
2 |
Correct |
60 ms |
15048 KB |
Output is correct |
3 |
Correct |
61 ms |
14912 KB |
Output is correct |
4 |
Correct |
54 ms |
13632 KB |
Output is correct |
5 |
Correct |
49 ms |
14172 KB |
Output is correct |
6 |
Correct |
55 ms |
13880 KB |
Output is correct |
7 |
Correct |
60 ms |
13956 KB |
Output is correct |
8 |
Correct |
47 ms |
14044 KB |
Output is correct |
9 |
Correct |
48 ms |
13988 KB |
Output is correct |
10 |
Correct |
43 ms |
13348 KB |
Output is correct |
11 |
Correct |
44 ms |
13496 KB |
Output is correct |
12 |
Correct |
44 ms |
12592 KB |
Output is correct |
13 |
Correct |
43 ms |
12708 KB |
Output is correct |
14 |
Correct |
46 ms |
13040 KB |
Output is correct |
15 |
Correct |
48 ms |
13760 KB |
Output is correct |
16 |
Correct |
47 ms |
13652 KB |
Output is correct |
17 |
Correct |
49 ms |
13628 KB |
Output is correct |
18 |
Correct |
49 ms |
13504 KB |
Output is correct |
19 |
Correct |
47 ms |
13624 KB |
Output is correct |
20 |
Correct |
43 ms |
13920 KB |
Output is correct |
21 |
Correct |
43 ms |
13896 KB |
Output is correct |
22 |
Correct |
48 ms |
13752 KB |
Output is correct |
23 |
Correct |
48 ms |
13880 KB |
Output is correct |
24 |
Correct |
48 ms |
14012 KB |
Output is correct |
25 |
Correct |
49 ms |
14120 KB |
Output is correct |
26 |
Correct |
47 ms |
13828 KB |
Output is correct |
27 |
Correct |
48 ms |
13892 KB |
Output is correct |
28 |
Correct |
48 ms |
13948 KB |
Output is correct |
29 |
Correct |
44 ms |
12976 KB |
Output is correct |
30 |
Correct |
46 ms |
13296 KB |
Output is correct |
31 |
Correct |
6 ms |
2424 KB |
Output is correct |
32 |
Correct |
6 ms |
2424 KB |
Output is correct |
33 |
Correct |
6 ms |
2792 KB |
Output is correct |
34 |
Correct |
6 ms |
2424 KB |
Output is correct |
35 |
Correct |
6 ms |
2424 KB |
Output is correct |
36 |
Correct |
6 ms |
2424 KB |
Output is correct |
37 |
Correct |
5 ms |
2516 KB |
Output is correct |
38 |
Correct |
6 ms |
2300 KB |
Output is correct |
39 |
Correct |
4 ms |
2288 KB |
Output is correct |
40 |
Correct |
5 ms |
2512 KB |
Output is correct |
41 |
Correct |
5 ms |
2300 KB |
Output is correct |
42 |
Correct |
4 ms |
2288 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
2296 KB |
Output is correct |
2 |
Correct |
6 ms |
2288 KB |
Output is correct |
3 |
Correct |
5 ms |
2380 KB |
Output is correct |
4 |
Correct |
11 ms |
4248 KB |
Output is correct |
5 |
Correct |
11 ms |
4268 KB |
Output is correct |
6 |
Correct |
11 ms |
4248 KB |
Output is correct |
7 |
Correct |
11 ms |
4240 KB |
Output is correct |
8 |
Correct |
11 ms |
4396 KB |
Output is correct |
9 |
Correct |
43 ms |
14748 KB |
Output is correct |
10 |
Correct |
43 ms |
14608 KB |
Output is correct |
11 |
Correct |
41 ms |
14748 KB |
Output is correct |
12 |
Correct |
5 ms |
2396 KB |
Output is correct |
13 |
Correct |
5 ms |
2288 KB |
Output is correct |
14 |
Correct |
4 ms |
2300 KB |
Output is correct |
15 |
Correct |
4 ms |
2288 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
62 ms |
14912 KB |
Output is correct |
2 |
Correct |
62 ms |
14896 KB |
Output is correct |
3 |
Correct |
62 ms |
14920 KB |
Output is correct |
4 |
Correct |
49 ms |
13516 KB |
Output is correct |
5 |
Correct |
47 ms |
14480 KB |
Output is correct |
6 |
Correct |
49 ms |
13892 KB |
Output is correct |
7 |
Correct |
48 ms |
14136 KB |
Output is correct |
8 |
Correct |
49 ms |
13884 KB |
Output is correct |
9 |
Correct |
49 ms |
13880 KB |
Output is correct |
10 |
Correct |
44 ms |
13428 KB |
Output is correct |
11 |
Correct |
43 ms |
13368 KB |
Output is correct |
12 |
Correct |
43 ms |
12460 KB |
Output is correct |
13 |
Correct |
41 ms |
12456 KB |
Output is correct |
14 |
Correct |
45 ms |
13124 KB |
Output is correct |
15 |
Correct |
48 ms |
13748 KB |
Output is correct |
16 |
Correct |
47 ms |
13632 KB |
Output is correct |
17 |
Correct |
47 ms |
13552 KB |
Output is correct |
18 |
Correct |
48 ms |
13500 KB |
Output is correct |
19 |
Correct |
47 ms |
13496 KB |
Output is correct |
20 |
Correct |
43 ms |
14008 KB |
Output is correct |
21 |
Correct |
43 ms |
13788 KB |
Output is correct |
22 |
Correct |
48 ms |
14004 KB |
Output is correct |
23 |
Correct |
48 ms |
13752 KB |
Output is correct |
24 |
Correct |
47 ms |
13752 KB |
Output is correct |
25 |
Correct |
48 ms |
13880 KB |
Output is correct |
26 |
Correct |
49 ms |
14008 KB |
Output is correct |
27 |
Correct |
48 ms |
14008 KB |
Output is correct |
28 |
Correct |
48 ms |
13640 KB |
Output is correct |
29 |
Correct |
45 ms |
12904 KB |
Output is correct |
30 |
Correct |
46 ms |
13480 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
60 ms |
14912 KB |
Output is correct |
2 |
Correct |
60 ms |
14852 KB |
Output is correct |
3 |
Correct |
61 ms |
14912 KB |
Output is correct |
4 |
Correct |
49 ms |
13496 KB |
Output is correct |
5 |
Correct |
52 ms |
14520 KB |
Output is correct |
6 |
Correct |
48 ms |
13880 KB |
Output is correct |
7 |
Correct |
50 ms |
14032 KB |
Output is correct |
8 |
Correct |
48 ms |
13912 KB |
Output is correct |
9 |
Correct |
48 ms |
13888 KB |
Output is correct |
10 |
Correct |
43 ms |
13552 KB |
Output is correct |
11 |
Correct |
43 ms |
13396 KB |
Output is correct |
12 |
Correct |
46 ms |
12456 KB |
Output is correct |
13 |
Correct |
41 ms |
12484 KB |
Output is correct |
14 |
Correct |
44 ms |
13040 KB |
Output is correct |
15 |
Correct |
47 ms |
13752 KB |
Output is correct |
16 |
Correct |
47 ms |
13808 KB |
Output is correct |
17 |
Correct |
49 ms |
13720 KB |
Output is correct |
18 |
Correct |
47 ms |
13604 KB |
Output is correct |
19 |
Correct |
52 ms |
13724 KB |
Output is correct |
20 |
Correct |
43 ms |
14136 KB |
Output is correct |
21 |
Correct |
42 ms |
13892 KB |
Output is correct |
22 |
Correct |
48 ms |
13756 KB |
Output is correct |
23 |
Correct |
48 ms |
13676 KB |
Output is correct |
24 |
Correct |
47 ms |
13888 KB |
Output is correct |
25 |
Correct |
48 ms |
13888 KB |
Output is correct |
26 |
Correct |
48 ms |
13760 KB |
Output is correct |
27 |
Correct |
47 ms |
13888 KB |
Output is correct |
28 |
Correct |
48 ms |
14064 KB |
Output is correct |
29 |
Correct |
44 ms |
12848 KB |
Output is correct |
30 |
Correct |
47 ms |
13132 KB |
Output is correct |
31 |
Correct |
6 ms |
2288 KB |
Output is correct |
32 |
Correct |
6 ms |
2424 KB |
Output is correct |
33 |
Correct |
6 ms |
2664 KB |
Output is correct |
34 |
Correct |
6 ms |
2476 KB |
Output is correct |
35 |
Correct |
6 ms |
2288 KB |
Output is correct |
36 |
Correct |
6 ms |
2412 KB |
Output is correct |
37 |
Correct |
5 ms |
2424 KB |
Output is correct |
38 |
Correct |
5 ms |
2528 KB |
Output is correct |
39 |
Correct |
4 ms |
2288 KB |
Output is correct |
40 |
Correct |
6 ms |
2532 KB |
Output is correct |
41 |
Correct |
4 ms |
2416 KB |
Output is correct |
42 |
Correct |
5 ms |
2524 KB |
Output is correct |