This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "Joi.h"
#include <bits/stdc++.h>
using namespace std;
#define MAXN 10010
#define INF 1000000000
static vector<int> g[MAXN];
static vector<long long> dist(MAXN, INF);
void Joi(int N, int M, int A[], int B[], long long X, int T)
{
for(int i = 0; i < M; i++)
{
g[A[i]].push_back(B[i]);
g[B[i]].push_back(A[i]);
}
for(int i = 0; i < N; i++)
{
long long x = i % 60;
if(X & (1LL << x))
{
MessageBoard(i, 1);
}
else
{
MessageBoard(i, 0);
}
}
// cout << "hello" << endl;
}
#include "Ioi.h"
#include <bits/stdc++.h>
using namespace std;
#define MAXN 10010
#define INF 1000000000
static vector<int> g[MAXN];
static vector<long long> dist(MAXN, INF);
static vector<bool> vis(MAXN, false);
static vector<int> parent(MAXN);
static long long ans = 0;
static set<int> already_taken;
static int Find(int x)
{
if(x == parent[x]) return x;
return parent[x] = Find(parent[x]);
}
static void Unite(int a, int b)
{
a = Find(a), b = Find(b);
parent[a] = b;
}
static void dfs(int node, int par, long long val)
{
// cout << "node = " << node << ", val = " << val << "\n";
// cout << "ans = " << ans << "\n";
if(vis[node])
{
assert(par != -1);
int value = Move(par);
return;
}
vis[node] = true;
if(val == 1 && !already_taken.count(node % 60))
{
long long x = node % 60;
ans += (1LL << x);
already_taken.insert(x);
}
for(int to: g[node])
{
// cout << "to: " << to << "\n";
if(!vis[to])
{
int value = Move(to);
dfs(to, node, value);
}
}
if(par != -1)
{
int value = Move(par);
}
}
long long Ioi(int N, int M, int A[], int B[], int P, int V, int T)
{
// cout << "hello" << endl;
for(long long i = 0; i < N; i++)
{
parent[i] = i;
}
int cnt = 0;
for(int i = 0; i < M; i++)
{
if(Find(A[i]) != Find(B[i]))
{
Unite(A[i], B[i]);
g[A[i]].push_back(B[i]);
g[B[i]].push_back(A[i]);
cnt++;
}
}
// cout << "hello" << endl;
assert(cnt == N - 1);
// cout << "hello x2" << endl;
dfs(P, -1, (long long)(V));
// cout << "hello x3" << endl;
return ans;
}
Compilation message (stderr)
Ioi.cpp: In function 'void dfs(int, int, long long int)':
Ioi.cpp:35:13: warning: unused variable 'value' [-Wunused-variable]
35 | int value = Move(par);
| ^~~~~
Ioi.cpp:56:13: warning: unused variable 'value' [-Wunused-variable]
56 | int value = Move(par);
| ^~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |