Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
31950 | LYLAKIOI | 【S】T3 | C++ | 解答错误 | 0 | 363 MS | 30116 KB | 1134 | 2024-08-28 14:52:24 |
#include<bits/stdc++.h> #define up(i,l,r) for(int i=(l);i<=(r);++i) #define down(i,l,r) for(int i=(l);i>=(r);--i) #define pi pair<int,int> #define p1 first #define p2 second #define m_p make_pair #define p_b push_back using namespace std; typedef long long ll; typedef unsigned long long ull; const int maxn=5e5+10,mod=998244353; inline ll read(){ ll x=0;short t=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')t=-1;ch=getchar();} while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar(); return x*t; } int n,p[maxn],fa[maxn]; vector<int>v[maxn]; void dfs(int u){ for(int x:v[u])if(x!=fa[u]){ fa[x]=u;dfs(x); } } void slv(){ n=read();int q=read(); up(i,1,n-1){int x=read(),y=read();v[x].p_b(y),v[y].p_b(x);} up(i,1,n)read();dfs(1); while(q--){ int a=read(),b=read(),c=read(),d=read(); if(fa[b]==a)swap(a,b);if(c!=a&&d!=a)assert(0); if(c!=a)fa[a]=c;else fa[a]=d; } } int main(){ //freopen("bird.in","r",stdin); //freopen("bird.out","w",stdout); slv(); fclose(stdin); fclose(stdout); return 0; }