#include "Joi.h"
#include <bits/stdc++.h>
using namespace std;
#define in in2
#define timer timer2
#define V V2
static const int N2 = 1e4 + 5;
static int in[N2], timer;
vector<int> V[N2];
long long x;
void DFS(int u) {
in[u] = ++timer; //cout << "+" << u << endl;
for(int i = 0; i < V[u].size(); i++) {
if(!in[V[u][i]]) DFS(V[u][i]);
}
MessageBoard(u, ((1ll << (in[u] % 60)) & x) ? 1 : 0);
}
void Joi(int N, int M, int A[], int B[], long long X, int T) {
x = X;
for(int i = 0; i < M; i++) {
V[A[i]].push_back(B[i]);
V[B[i]].push_back(A[i]);
}
for(int i = 0; i < N; i++) {
sort(V[i].begin(), V[i].end());
// if(!i) for(int j = 0; j < V[i].size(); j++) cout << V[i][j] << " ";
}
DFS(0);
}
#include "Ioi.h"
#include <bits/stdc++.h>
using namespace std;
static const int N = 1e4 + 5;
#define ll long long
ll p[N], in[N], timer, f[60], C, Val, cur;
vector<int> V[N], adj[N];
int POS[N];
map<int,int> F[N];
void dfs(int u) {
in[u] = ++timer; POS[in[u]] = u;
for(int i = 0; i < V[u].size(); i++) {
if(!in[V[u][i]]) dfs(V[u][i]), adj[u].push_back(V[u][i]), p[V[u][i]] = u;
}
}
ll ans = 0;
long long move_(int u, int x) {
assert(cur == u && F[u][x]);
// cout << u << "-->" << x << endl;
cur = x;
return Move(x);
}
void dfs2(int u) {
if(!f[in[u] % 60]) --C;
f[in[u] % 60] = 1; ans |= (1ll << (in[u] % 60)) * Val;
if(!C) return;
for(int i = 0; i < adj[u].size(); i++) {
if(!C) return;
if(!f[in[adj[u][i]] % 60]) Val = move_(u, adj[u][i]), dfs2(adj[u][i]);
}
if(!C) return;
// cout << "-" << endl;
Val = move_(u, p[u]);
}
long long Ioi(int N, int M, int A[], int B[], int v, int P, int t) {
for(int i = 0; i < M; i++) {
V[A[i]].push_back(B[i]);
V[B[i]].push_back(A[i]);
F[A[i]][B[i]] = F[B[i]][A[i]] = 1;
}
for(int i = 0; i < N; i++) {
sort(V[i].begin(), V[i].end());
}
C = 60;
dfs(0);
Val = P; cur = v;
while(C) {
dfs2(v);
if(C) v = p[v];
}
return ans;
}
Compilation message
Joi.cpp: In function 'void DFS(int)':
Joi.cpp:13:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
13 | for(int i = 0; i < V[u].size(); i++) {
| ~~^~~~~~~~~~~~~
Ioi.cpp: In function 'void dfs(int)':
Ioi.cpp:12:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
12 | for(int i = 0; i < V[u].size(); i++) {
| ~~^~~~~~~~~~~~~
Ioi.cpp: In function 'void dfs2(int)':
Ioi.cpp:27:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
27 | for(int i = 0; i < adj[u].size(); i++) {
| ~~^~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1800 KB |
Output is correct |
2 |
Correct |
2 ms |
1876 KB |
Output is correct |
3 |
Correct |
2 ms |
1796 KB |
Output is correct |
4 |
Correct |
2 ms |
1796 KB |
Output is correct |
5 |
Correct |
2 ms |
1796 KB |
Output is correct |
6 |
Correct |
2 ms |
1868 KB |
Output is correct |
7 |
Correct |
2 ms |
1800 KB |
Output is correct |
8 |
Correct |
2 ms |
1800 KB |
Output is correct |
9 |
Correct |
2 ms |
1808 KB |
Output is correct |
10 |
Correct |
2 ms |
1864 KB |
Output is correct |
11 |
Correct |
7 ms |
2668 KB |
Output is correct |
12 |
Correct |
2 ms |
1804 KB |
Output is correct |
13 |
Correct |
2 ms |
1800 KB |
Output is correct |
14 |
Correct |
2 ms |
1800 KB |
Output is correct |
15 |
Correct |
2 ms |
1808 KB |
Output is correct |
16 |
Correct |
2 ms |
1808 KB |
Output is correct |
17 |
Correct |
3 ms |
1800 KB |
Output is correct |
18 |
Correct |
2 ms |
1800 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
7112 KB |
Output is correct |
2 |
Correct |
28 ms |
7552 KB |
Output is correct |
3 |
Correct |
30 ms |
7528 KB |
Output is correct |
4 |
Correct |
16 ms |
4772 KB |
Output is correct |
5 |
Correct |
16 ms |
5388 KB |
Output is correct |
6 |
Correct |
16 ms |
5156 KB |
Output is correct |
7 |
Correct |
19 ms |
5152 KB |
Output is correct |
8 |
Correct |
17 ms |
5212 KB |
Output is correct |
9 |
Correct |
18 ms |
5412 KB |
Output is correct |
10 |
Correct |
16 ms |
4736 KB |
Output is correct |
11 |
Correct |
16 ms |
4736 KB |
Output is correct |
12 |
Correct |
18 ms |
4560 KB |
Output is correct |
13 |
Correct |
16 ms |
4572 KB |
Output is correct |
14 |
Correct |
15 ms |
4508 KB |
Output is correct |
15 |
Correct |
15 ms |
4856 KB |
Output is correct |
16 |
Correct |
22 ms |
4876 KB |
Output is correct |
17 |
Correct |
17 ms |
4828 KB |
Output is correct |
18 |
Correct |
16 ms |
4704 KB |
Output is correct |
19 |
Correct |
16 ms |
4764 KB |
Output is correct |
20 |
Correct |
13 ms |
5372 KB |
Output is correct |
21 |
Correct |
18 ms |
5420 KB |
Output is correct |
22 |
Correct |
19 ms |
5044 KB |
Output is correct |
23 |
Correct |
19 ms |
5240 KB |
Output is correct |
24 |
Correct |
18 ms |
5096 KB |
Output is correct |
25 |
Correct |
17 ms |
5224 KB |
Output is correct |
26 |
Correct |
16 ms |
5276 KB |
Output is correct |
27 |
Correct |
16 ms |
5288 KB |
Output is correct |
28 |
Correct |
20 ms |
5328 KB |
Output is correct |
29 |
Correct |
18 ms |
4936 KB |
Output is correct |
30 |
Correct |
18 ms |
5024 KB |
Output is correct |
31 |
Correct |
2 ms |
1796 KB |
Output is correct |
32 |
Correct |
2 ms |
1868 KB |
Output is correct |
33 |
Correct |
2 ms |
1812 KB |
Output is correct |
34 |
Correct |
2 ms |
1796 KB |
Output is correct |
35 |
Runtime error |
3 ms |
2952 KB |
Execution killed with signal 6 |
36 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1804 KB |
Output is correct |
2 |
Correct |
2 ms |
1812 KB |
Output is correct |
3 |
Correct |
2 ms |
1776 KB |
Output is correct |
4 |
Correct |
3 ms |
2492 KB |
Output is correct |
5 |
Correct |
3 ms |
2484 KB |
Output is correct |
6 |
Correct |
4 ms |
2456 KB |
Output is correct |
7 |
Correct |
4 ms |
2440 KB |
Output is correct |
8 |
Correct |
4 ms |
2476 KB |
Output is correct |
9 |
Correct |
16 ms |
6180 KB |
Output is correct |
10 |
Correct |
17 ms |
6176 KB |
Output is correct |
11 |
Correct |
15 ms |
6172 KB |
Output is correct |
12 |
Correct |
2 ms |
1796 KB |
Output is correct |
13 |
Correct |
2 ms |
1796 KB |
Output is correct |
14 |
Correct |
2 ms |
1804 KB |
Output is correct |
15 |
Correct |
2 ms |
1808 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
7104 KB |
Output is correct |
2 |
Correct |
31 ms |
7460 KB |
Output is correct |
3 |
Correct |
35 ms |
7424 KB |
Output is correct |
4 |
Correct |
18 ms |
4760 KB |
Output is correct |
5 |
Correct |
18 ms |
5792 KB |
Output is correct |
6 |
Correct |
18 ms |
5420 KB |
Output is correct |
7 |
Correct |
18 ms |
5316 KB |
Output is correct |
8 |
Correct |
23 ms |
4916 KB |
Output is correct |
9 |
Correct |
16 ms |
5168 KB |
Output is correct |
10 |
Correct |
17 ms |
4776 KB |
Output is correct |
11 |
Correct |
18 ms |
4848 KB |
Output is correct |
12 |
Correct |
15 ms |
4480 KB |
Output is correct |
13 |
Correct |
15 ms |
4492 KB |
Output is correct |
14 |
Correct |
17 ms |
4468 KB |
Output is correct |
15 |
Correct |
20 ms |
4892 KB |
Output is correct |
16 |
Correct |
19 ms |
4848 KB |
Output is correct |
17 |
Correct |
17 ms |
4764 KB |
Output is correct |
18 |
Correct |
21 ms |
4908 KB |
Output is correct |
19 |
Correct |
20 ms |
4808 KB |
Output is correct |
20 |
Correct |
14 ms |
5408 KB |
Output is correct |
21 |
Correct |
15 ms |
5412 KB |
Output is correct |
22 |
Correct |
19 ms |
5148 KB |
Output is correct |
23 |
Correct |
20 ms |
5096 KB |
Output is correct |
24 |
Correct |
16 ms |
5140 KB |
Output is correct |
25 |
Correct |
16 ms |
5228 KB |
Output is correct |
26 |
Correct |
16 ms |
5232 KB |
Output is correct |
27 |
Correct |
18 ms |
5404 KB |
Output is correct |
28 |
Correct |
20 ms |
5012 KB |
Output is correct |
29 |
Correct |
16 ms |
4820 KB |
Output is correct |
30 |
Correct |
25 ms |
5088 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
7112 KB |
Output is correct |
2 |
Correct |
34 ms |
7448 KB |
Output is correct |
3 |
Correct |
34 ms |
7440 KB |
Output is correct |
4 |
Correct |
19 ms |
4752 KB |
Output is correct |
5 |
Correct |
18 ms |
6008 KB |
Output is correct |
6 |
Correct |
18 ms |
5184 KB |
Output is correct |
7 |
Correct |
23 ms |
5188 KB |
Output is correct |
8 |
Correct |
17 ms |
5252 KB |
Output is correct |
9 |
Correct |
20 ms |
5148 KB |
Output is correct |
10 |
Correct |
22 ms |
4640 KB |
Output is correct |
11 |
Correct |
19 ms |
4768 KB |
Output is correct |
12 |
Correct |
14 ms |
4496 KB |
Output is correct |
13 |
Correct |
15 ms |
4592 KB |
Output is correct |
14 |
Correct |
15 ms |
4704 KB |
Output is correct |
15 |
Correct |
16 ms |
4884 KB |
Output is correct |
16 |
Correct |
17 ms |
4860 KB |
Output is correct |
17 |
Correct |
16 ms |
4760 KB |
Output is correct |
18 |
Correct |
18 ms |
4712 KB |
Output is correct |
19 |
Correct |
17 ms |
4796 KB |
Output is correct |
20 |
Correct |
15 ms |
5368 KB |
Output is correct |
21 |
Correct |
17 ms |
5412 KB |
Output is correct |
22 |
Correct |
22 ms |
5076 KB |
Output is correct |
23 |
Correct |
18 ms |
5196 KB |
Output is correct |
24 |
Correct |
19 ms |
5112 KB |
Output is correct |
25 |
Correct |
16 ms |
5216 KB |
Output is correct |
26 |
Correct |
15 ms |
5048 KB |
Output is correct |
27 |
Correct |
16 ms |
5412 KB |
Output is correct |
28 |
Correct |
20 ms |
5372 KB |
Output is correct |
29 |
Correct |
19 ms |
4996 KB |
Output is correct |
30 |
Correct |
17 ms |
5152 KB |
Output is correct |
31 |
Correct |
2 ms |
1804 KB |
Output is correct |
32 |
Correct |
2 ms |
1868 KB |
Output is correct |
33 |
Correct |
2 ms |
1808 KB |
Output is correct |
34 |
Correct |
2 ms |
1800 KB |
Output is correct |
35 |
Correct |
2 ms |
1868 KB |
Output is correct |
36 |
Correct |
2 ms |
1752 KB |
Output is correct |
37 |
Correct |
2 ms |
1804 KB |
Output is correct |
38 |
Correct |
2 ms |
1800 KB |
Output is correct |
39 |
Correct |
2 ms |
1800 KB |
Output is correct |
40 |
Runtime error |
4 ms |
2948 KB |
Execution killed with signal 6 |
41 |
Halted |
0 ms |
0 KB |
- |