# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1141717 | Noproblem29 | Collapse (JOI18_collapse) | C++20 | 220 ms | 100176 KiB |
#include "collapse.h"
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+100;
#define ll long long
int n,m,q;
int p[N];
int pos[N];
vector<int>ans;
int dsu(int x){
while(p[x]>=0)x=p[x];
return x;
}
int sz;
stack<tuple<int,int,bool>>st;
void merge(int x,int y){
x=dsu(x);
y=dsu(y);
if(x==y)return;
if(p[x]<p[y])swap(x,y);
st.push({x,p[x],(p[x]==p[y])});
if(p[x]==p[y]){
p[y]--;
}
sz--;
p[x]=y;
}
void rollback(int t){
while(st.size()>t){
auto [x,pxe,ch]=st.top();
# | 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... |