0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-26 05:51:59 +00:00

chore: delete files added by mistake

This commit is contained in:
Baoshuo Ren 2023-01-29 15:11:56 +08:00
parent 885f9e76f8
commit d74f0bbea3
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
2 changed files with 0 additions and 294 deletions

View File

@ -1,188 +0,0 @@
#include <iostream>
#include <stack>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 1e5 + 5;
int n, m;
class LinkCutTree {
private:
struct node {
size_t l, r, f;
unsigned v, s;
bool rev;
node()
: l(0), r(0), f(0), s(0), v(0), rev(false) {}
node(unsigned _v, size_t _f)
: l(0), r(0), f(_f), s(_v), v(_v), rev(false) {}
size_t &child(unsigned x) {
return !x ? l : r;
}
} tr[N];
inline void pushup(size_t u) {
tr[u].s = tr[tr[u].l].s + tr[u].v + tr[tr[u].r].s;
}
inline void pushdown(const size_t &u) {
if (!tr[u].rev) return;
std::swap(tr[u].l, tr[u].r);
tr[tr[u].l].rev = !tr[tr[u].l].rev;
tr[tr[u].r].rev = !tr[tr[u].r].rev;
tr[u].rev = false;
}
unsigned relation(const size_t &u) {
return u == tr[tr[u].f].l ? 0 : 1;
}
bool isRoot(const size_t &u) {
return tr[tr[u].f].l != u && tr[tr[u].f].r != u;
}
void rotate(size_t u) {
size_t p = tr[u].f;
unsigned x = relation(u);
if (!isRoot(p)) {
tr[tr[p].f].child(relation(p)) = u;
}
tr[u].f = tr[p].f;
if (tr[u].child(x ^ 1)) {
tr[tr[u].child(x ^ 1)].f = p;
}
tr[p].child(x) = tr[u].child(x ^ 1);
tr[u].child(x ^ 1) = p;
tr[p].f = u;
pushup(p);
pushup(u);
}
void splay(size_t u) {
std::stack<size_t> st;
size_t cur = u;
st.push(cur);
while (!isRoot(cur)) {
st.push(tr[cur].f);
cur = tr[cur].f;
}
while (!st.empty()) {
pushdown(st.top());
st.pop();
}
while (!isRoot(u)) {
if (isRoot(tr[u].f)) {
rotate(u);
} else if (relation(u) == relation(tr[u].f)) {
rotate(tr[u].f);
rotate(u);
} else {
rotate(u);
rotate(u);
}
}
}
void access(size_t u) {
for (size_t f = 0; u; u = tr[f = u].f) {
splay(u);
tr[u].r = f;
pushup(u);
}
}
void makeRoot(const size_t &u) {
access(u);
splay(u);
tr[u].rev = !tr[u].rev;
}
size_t findRoot(size_t u) {
access(u);
splay(u);
while (tr[u].l) {
u = tr[u].l;
}
return u;
}
void split(const size_t &x, const size_t &y) {
makeRoot(x);
access(y);
splay(y);
}
public:
void set(int p, int v) {
tr[p].s = tr[p].v = v;
}
unsigned query(int x, int y) {
split(x, y);
return tr[y].s;
}
bool check(int x, int y) {
return findRoot(x) == findRoot(y);
}
void link(const int &x, const int &y) {
makeRoot(x);
if (findRoot(y) != x) {
tr[x].f = y;
}
}
void cut(int x, int y) {
split(x, y);
if (tr[y].l == x) {
tr[y].l = 0;
tr[x].f = 0;
}
}
void change(int p, int v) {
access(p);
splay(p);
tr[p].v = v;
pushup(p);
}
} lct[2];
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n;
for (int i = 1, x, y; i < n; i++) {
cin >> x >> y;
}
cin >> m;
while (m--) {
//
}
return 0;
}

View File

@ -1,106 +0,0 @@
#include <iostream>
#include <queue>
#include <vector>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 2e6 + 5;
const int INF = 0x3f3f3f3f;
int n, q, t, cnt = 1, pos = 1, lst,
a[N], dep[N], fa[N][std::__lg(N) + 1];
std::vector<int> g[N];
void bfs(int s) {
std::fill_n(dep, N, INF);
std::queue<int> q;
q.emplace(s);
dep[0] = 0;
dep[s] = 1;
while (!q.empty()) {
int u = q.front();
q.pop();
for (int v : g[u]) {
if (dep[v] > dep[u] + 1) {
dep[v] = dep[u] + 1;
q.emplace(v);
fa[v][0] = u;
for (int k = 1; k <= std::__lg(n); k++) {
fa[v][k] = fa[fa[v][k - 1]][k - 1];
}
}
}
}
}
int lca(int x, int y) {
if (dep[x] < dep[y]) std::swap(x, y);
for (int k = std::__lg(n); k >= 0; k--) {
if (dep[fa[x][k]] >= dep[y]) {
x = fa[x][k];
}
}
if (x == y) return x;
for (int k = std::__lg(n); k >= 0; k--) {
if (fa[x][k] != fa[y][k]) {
x = fa[x][k];
y = fa[y][k];
}
}
return fa[x][0];
}
constexpr int get(int x) {
return x * (x - 1) / 2;
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> q >> t;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = 1; i <= n; i++) {
for (int j = i * (i - 1) / 2 + 1; j <= i * (i - 1) / 2 + i; j++) {
if (a[pos] == j) {
g[j].emplace_back(++cnt);
g[j].emplace_back(++cnt);
pos++;
} else {
g[j].emplace_back(++cnt);
}
}
}
bfs(1);
while (q--) {
int x, y;
cin >> x >> y;
x = (x - 1 + t * lst) % ((n + 1) * (n + 2) / 2) + 1;
y = (y - 1 + t * lst) % ((n + 1) * (n + 2) / 2) + 1;
cout << (lst = lca(x, y)) << endl;
}
return 0;
}