0.1 is 0.1 ...... Weak ...... Just save it for the moment to pave the way for future positive solutions.
Q: What oi do you learn?
A: I can't learn Oi. I want to roll rough ......
Explanation:
In the first line, enter point N and the two query points Q1 and Q2.
In the second row, enter father Father [I] for each vertex.
One row of output ans = recent common ancestor ......
Will not multiply ...... I wrote something that looks like a positive solution, but it's actually a violent stuff ......
#include<iostream>#include<cstdlib>#include<cstdio>using namespace std;int father[500];int q1,q2,h1,h2,n,t1,t2,ans,s1,s2,jump;bool flag;bool pd(int q1,int q2){ if (father[q1]==q2) {ans=q2;flag=false;return false;} if (father[q2]==q1) {ans=q1;flag=false;return false;} if (q1==q2) {ans=q1;flag=false;return false;} return true;}int main(){ cin>>n>>q1>>q2; for (int i=1;i<=n;i++) cin>>father[i]; t1=q1;t2=q2; while (t1!=0) {t1=father[t1];h1++;} while (t2!=0) {t2=father[t2];h2++;} int gap=abs(h1-h2); if (h1
I always think & (Pd (Q1, q2) is really good ............ I was so weak that I wrote such a powerful thing ............ (Hzwer: What are you doing with flag? Me: Workshop)
[LCA] 0.1 recent common ancestor in a single group of trees that do not multiply the number of violent trees