Submission #492558

# Submission time Handle Problem Language Result Execution time Memory
492558 2021-12-08T00:22:21 Z cgiosy Usmjeri (COCI17_usmjeri) C++17
0 / 140
134 ms 27288 KB
#include <bits/stdc++.h>
using namespace std;
constexpr int MOD=1e9+7;

int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	int N, M;
	cin>>N>>M;
	int D[N], P[N], E[N*2], F[N*2], G[N]{};
	for(int i=1; i<N; i++) {
		int a, b;
		cin>>a>>b; --a, --b;
		E[i*2]=b, F[i*2]=G[a], G[a]=i*2;
		E[i*2+1]=a, F[i*2+1]=G[b], G[b]=i*2+1;
	}
	function<void(int)> dfs=[&](int i) {
		for(int e=G[i]; e; e=F[e]) if(int&j=E[e]; j!=P[i])
			D[j]=D[i]+1, P[j]=i, dfs(j);
	};
	D[0]=1, P[0]=0; dfs(0);

	function<int(int)> root=[&](int i) { return !D[i] ? P[i]=root(P[i]) : i; };
	while(M--) {
		int a, b;
		cin>>a>>b; --a, --b;
		for(a=root(a); a!=(b=root(b)); D[b]=0) if(D[a]>D[b]) swap(a, b);
	}

	int v=0;
	cout<<v<<'\n';
}
# Verdict Execution time Memory Grader output
1 Incorrect 52 ms 9184 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 117 ms 27288 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 122 ms 8932 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 132 ms 9024 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 134 ms 9204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 134 ms 9340 KB Output isn't correct
2 Halted 0 ms 0 KB -