QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#199876 | #7347. HDRF | whsyhyyh# | WA | 1ms | 7372kb | C++14 | 756b | 2023-10-04 14:27:13 | 2023-10-04 14:27:13 |
Judging History
answer
#include<bits/stdc++.h>
#define N 100010
#define rep(i,l,r) for(int i=l;i<=r;i++)
using namespace std;
int rd() {
int res=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9') {if(ch=='-') f*=-1;ch=getchar();}
while(ch>='0'&&ch<='9') res=(res<<1)+(res<<3)+(ch^48),ch=getchar();
return res*f;
}
int n,fat[N],a[N],r[N];
vector<int>G[N];
bool cmp(int x,int y) {
return r[x]<r[y];
}
void Deal_first(int x) {
r[x]=a[x];
for(auto v:G[x]) {
Deal_first(v);
r[x]=min(r[x],r[v]);
}
sort(G[x].begin(),G[x].end(),cmp);
}
void dfs(int x) {
for(auto v:G[x]) dfs(v);
printf("%d ",x);
}
int main() {
n=rd();
rep(i,2,n) {
fat[i]=rd();
G[fat[i]].push_back(i);
}
rep(i,1,n) a[i]=rd();
Deal_first(1);
dfs(1);
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 7372kb
input:
5 4 4 1 1 3 5 2 1 4
output:
3 2 4 5 1
result:
ok 5 number(s): "3 2 4 5 1"
Test #2:
score: 0
Accepted
time: 1ms
memory: 6944kb
input:
2 1 1 2
output:
2 1
result:
ok 2 number(s): "2 1"
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 6168kb
input:
100 85 42 34 7 48 48 63 90 37 80 26 50 73 6 11 94 90 41 89 44 9 29 71 44 27 52 27 39 6 91 28 25 63 12 24 23 25 7 19 15 69 84 80 37 28 100 1 78 23 72 15 12 91 90 87 52 13 8 42 51 69 46 20 8 32 5 62 35 13 61 63 7 72 15 37 16 89 34 73 93 71 14 74 65 27 51 81 75 94 57 67 13 40 65 35 63 80 28 78 39 56 6 ...
output:
95 2 85 65 59 8 36 24 82 71 61 56 87 51 43 84 74 72 79 4 34 97 63 46 99 66 32 28 3 60 42 68 62 69 96 35 53 12 26 86 27 31 54 91 57 52 55 22 9 18 90 17 94 40 19 41 64 20 47 100 49 78 89 75 15 30 6 88 81 93 58 70 13 50 76 10 45 37 23 29 39 33 38 25 21 44 77 16 11 98 80 83 14 73 92 67 5 7 48 1
result:
wrong answer 12th numbers differ - expected: '43', found: '56'