ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#212759 | #3829. C | wangliwen123456 | Compile Error | / | / | C++ | 678b | 2024-10-20 10:37:12 | 2024-10-20 12:41:51 |
answer
#include<bits/stdc++.h>
using namespace std;
int m,n;
int fa[100005];
int d[100005];
vector<int> cl[100005];
void dfs(int x) {
d[x]=d[fa[x]]+1;
for(auto y:cl[x]) {
dfs(y);
}
}
int LAC(int x,int y) {
if(d[x]<d[y]) {
swap(x,y);
}
while(d[x]>d[y]) {
x=fa[x];
}
while(x!=y) {
x=fa[x];
y=fa[y];
}
return x;
}
int main() {
cin>>n;
for(int i=1,x,y;i<n;i++) {
cin>>x>>y;
cl[x].push_back(y);
fa[y]=x;
}
dfs(1);
cin>>m;
while(m--) {
int u,v;
cin>>u>>v;
cout<<LAC(u,v)<<"\n";
}
return 0;
}
Details
answer.code: In function 'void dfs(int)': answer.code:9:14: error: 'y' does not name a type for(auto y:cl[x]) {\x0d ^ answer.code:12:1: error: expected ';' before '}' token }\x0d ^ answer.code:12:1: error: expected primary-expression before '}' token answer.code:12:1: error: expected ';' before '}' token answer.code:12:1: error: expected primary-expression before '}' token answer.code:12:1: error: expected ')' before '}' token answer.code:12:1: error: expected primary-expression b...