QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#716718 | #9532. 长野原龙势流星群 | konata2828 | Compile Error | / | / | C++98 | 1003b | 2024-11-06 15:53:25 | 2024-11-06 15:53:25 |
Judging History
This is the latest submission verdict.
- [2024-11-06 15:53:25]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2024-11-06 15:53:25]
- Submitted
answer
// Hydro submission #672b2073a059678966636fce@1730879604403
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int N = 2e5 + 5;
const double eps = 1e-9;
int n, w[N], cnt[N], ans[N];
vector<int> g[N];
priority_queue<pair<double, int> > hep[N];
void dfs(int u){
cnt[u] = 1;
for(int v : g[u]){
dfs(v);
hep[u].push(make_pair((double)(ans[v]) / cnt[v], v));}
while(!hep[u].empty()){
if(hep[u].top().first <= (double)(ans[u]) / cnt[u] - eps)
break;
int v = hep[u].top().second; hep[u].pop();
cnt[u] += cnt[v], ans[u] += ans[v];
if(hep[u].size() < hep[v].size()) swap(hep[u], hep[v]);
while(!hep[v].empty()) hep[u].push(hep[v].top()), hep[v].pop();
}
return ;
}
signed main(){
cin >> n;
for(int i = 2, p; i <= n; i++)
cin >> p, g[p].push_back(i);
for(int i = 1; i <= n; i++) cin >> ans[i];
dfs(1);
for(int i = 1; i <= n; i++)
printf("%.10f\n", (double)(ans[i]) / cnt[i]);
return 0;
}
詳細信息
answer.code: In function ‘void dfs(long long int)’: answer.code:15:21: warning: range-based ‘for’ loops only available with ‘-std=c++11’ or ‘-std=gnu++11’ [-Wc++11-extensions] 15 | for(int v : g[u]){ | ^ answer.code:15:24: error: forming reference to reference type ‘std::vector<long long int>&’ 15 | for(int v : g[u]){ | ^ answer.code: In function ‘int main()’: answer.code:38:29: warning: format ‘%f’ expects argument of type ‘double’, but argument 2 has type ‘long double’ [-Wformat=] 38 | printf("%.10f\n", (double)(ans[i]) / cnt[i]); | ~~~~^ ~~~~~~~~~~~~~~~~~~~~~~~~~ | | | | double long double | %.10Lf