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 <vector>
#include <map>
using namespace std;
static vector<vector<int>> adj;
static vector<int> ord;
static map<int, int> bit;
static vector<bool> seen;
static void dfs(int at) {
seen[at] = true;
ord.push_back(at);
for (int it : adj[at]) {
if (seen[it]) continue;
dfs(it);
ord.push_back(at);
}
int b = (int)bit.size();
bit[at] = b % 60;
}
void Joi(int N, int M, int A[], int B[], long long X, int T) {
adj.resize(N);
seen.resize(N);
for (int i = 0; i < M; i ++) {
adj[A[i]].push_back(B[i]);
adj[B[i]].push_back(A[i]);
}
dfs(0);
ord.pop_back();
for(int i = 0; i < N; i++){
MessageBoard(i, (X >> bit[i]) & 1);
}
}
#include "Ioi.h"
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
using namespace std;
static vector<vector<int>> adj;
static vector<int> ord;
static map<int, int> bit;
static vector<bool> seen;
static map<int, int> bits;
static vector<int> par;
static void dfs(int at) {
seen[at] = true;
ord.push_back(at);
for (int it : adj[at]) {
if (seen[it]) continue;
par[it] = at;
dfs(it);
ord.push_back(at);
}
int b = (int)bit.size();
bit[at] = b % 60;
}
static void dfs2(int at) {
for (int it : adj[at]) {
if (bits.count(bit[it]) || it == par[at]) continue;
bits[bit[it]] = Move(it);
dfs2(it);
Move(at);
}
}
long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {
adj.resize(N);
seen.resize(N);
par.resize(N);
for (int i = 0; i < M; i ++) {
adj[A[i]].push_back(B[i]);
adj[B[i]].push_back(A[i]);
}
dfs(0);
ord.pop_back();
bits[bit[P]] = V;
while (bits.size() != 60) {
dfs2(P);
P = par[P];
if (bits.size() != 60) bits[bit[P]] = Move(P);
}
cerr << "bits: " << bits.size() << endl;
//int at = find(ord.begin(), ord.end(), P) - ord.begin();
//while ((int)bits.size() != 60) {
//at = (at + 1) % ord.size();
//cerr << "go to " << ord[at] << " get bit " << bit[ord[at]] << endl;
//bits[bit[ord[at]]] = Move(ord[at]);
//}
long long X = 0;
for (int i = 0; i < 60; ++i) {
X |= (long long)bits[i] << i;
}
return X;
}
# | 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... |