#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++) {
| ~~^~~~~~~~~~~~~
Joi.cpp: In function 'void Joi(int, int, int*, int*, long long int, int)':
Joi.cpp:26:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
26 | if(!i) for(int j = 0; j < V[i].size(); j++) cout << V[i][j] << " ";
| ~~^~~~~~~~~~~~~
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 |
Incorrect |
2 ms |
1804 KB |
Do not print anything on standard output. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
13 ms |
4084 KB |
Do not print anything on standard output. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
1808 KB |
Do not print anything on standard output. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
17 ms |
4004 KB |
Do not print anything on standard output. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
13 ms |
3984 KB |
Do not print anything on standard output. |
2 |
Halted |
0 ms |
0 KB |
- |