QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#54854 | #4433. Kitten and Roomba | Hubizon | WA | 2577ms | 99620kb | C++17 | 1.2kb | 2022-10-10 22:55:32 | 2022-10-10 22:55:33 |
Judging History
answer
#include <iostream>
#include <functional>
#include <vector>
using namespace std;
typedef long double ld;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int z;
cin >> z;
while (z--) {
int n, c;
cin >> n >> c;
vector<vector<int>> G(n);
for (int i = 0; i < n - 1; i++) {
int u, v;
cin >> u >> v;
--u, --v;
G[u].push_back(v);
G[v].push_back(u);
}
vector<int> P(n);
function<void(int, int)> DFS = [&](int u, int p) {
P[u] = p;
for (auto& v : G[u])
if (v != p) DFS(v, u);
};
DFS(0, n);
vector<pair<ld, ld>> V(n + 1);
V[c - 1].first = 1;
ld res = 0;
int m;
cin >> m;
while (m--) {
int a;
cin >> a; --a;
ld v = V[a].first + V[P[a]].second;
if (v == 0) continue;
res += v;
ld r = v / G[a].size();
V[a].second += r;
V[P[a]].first += r;
V[a].first = 0;
}
cout << res << '\n';
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 2577ms
memory: 99620kb
input:
2 1000000 315562 969409 917725 324847 719085 524235 603427 576843 433171 75335 238378 266746 487233 80422 95099 594363 96140 858172 261406 958326 466109 233845 350950 863969 345645 689972 81395 395383 27274 93913 208983 523722 380358 108074 172341 130041 692304 737158 383812 752080 33646 154356 6672...
output:
6.02829e+214 6.01996e+214
result:
wrong answer 1st numbers differ - expected: '5.60942', found: '60282900000000001546125523291820931421588537562445123488609453368588255414806163805037513654780040558328171505285942163503890658214894836179629598010649084359232615826913584963745793050917426363406142416573213704192.00000', error = '1074...