ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#213855 | #582. t1 | laiyishi | Compile Error | / | / | C++ | 570b | 2024-11-13 22:02:52 | 2024-11-13 23:10:23 |
answer
#include<bits/stdc++.h>
using namespace std;
int n;
int fa[100005],id[100005],a[100005],b[100005],vis[100005];
vector<int>g[100005];
void dfs(int u){
if(vis[u])return;
vis[u]=1;
for(int v:g[u]){
dfs(v);
}
printf("%d ",u);
}
bool cmp(int i,int j){
return a[i]<a[j];
}
int main(){
scanf("%d",&n);
for(int i=2;i<=n;i++)scanf("%d",&fa[i]);
for(int i=1;i<=n;i++)scanf("%d",&a[i]),id[i]=i;
stable_sort(id+1,id+n+1,cmp);
for(int i=1;i<=n;i++){
int u=id[i];
g[fa[u]].push_back(u);
}
for(int i=1;i<=n;i++)dfs(id[i]);
printf("\n");
}
详细
answer.code: In function 'void dfs(int)': answer.code:9:12: error: range-based 'for' loops are not allowed in C++98 mode for(int v:g[u]){\x0d ^ answer.code: In function 'int main()': answer.code:18:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result] scanf("%d",&n);\x0d ^ answer.code:19:41: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_resu...