Task: | Amsterdam Distance |
Sender: | Antti Röyskö |
Submission time: | 2017-10-24 19:38:32 +0300 |
Language: | C++ |
Status: | READY |
Result: | WRONG ANSWER |
test | verdict | time | |
---|---|---|---|
#1 | WRONG ANSWER | 0.03 s | details |
#2 | WRONG ANSWER | 0.05 s | details |
#3 | WRONG ANSWER | 0.04 s | details |
#4 | WRONG ANSWER | 0.04 s | details |
#5 | WRONG ANSWER | 0.04 s | details |
#6 | WRONG ANSWER | 0.05 s | details |
#7 | WRONG ANSWER | 0.04 s | details |
#8 | WRONG ANSWER | 0.04 s | details |
#9 | WRONG ANSWER | 0.04 s | details |
#10 | WRONG ANSWER | 0.04 s | details |
#11 | WRONG ANSWER | 0.03 s | details |
#12 | WRONG ANSWER | 0.03 s | details |
#13 | WRONG ANSWER | 0.04 s | details |
#14 | WRONG ANSWER | 0.04 s | details |
#15 | WRONG ANSWER | 0.04 s | details |
#16 | WRONG ANSWER | 0.05 s | details |
#17 | WRONG ANSWER | 0.03 s | details |
#18 | WRONG ANSWER | 0.04 s | details |
#19 | WRONG ANSWER | 0.04 s | details |
#20 | WRONG ANSWER | 0.03 s | details |
#21 | WRONG ANSWER | 0.03 s | details |
#22 | WRONG ANSWER | 0.04 s | details |
#23 | WRONG ANSWER | 0.04 s | details |
#24 | WRONG ANSWER | 0.05 s | details |
#25 | WRONG ANSWER | 0.04 s | details |
#26 | WRONG ANSWER | 0.04 s | details |
#27 | WRONG ANSWER | 0.05 s | details |
#28 | WRONG ANSWER | 0.04 s | details |
#29 | WRONG ANSWER | 0.04 s | details |
#30 | WRONG ANSWER | 0.03 s | details |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:30:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (int i = 0; i < offers.size(); ++i) { ^ input/code.cpp:69:35: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (int i = 0; i < revised.size(); ++i) { ^
Code
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <utility> #include <math.h> #include <iomanip> const long double inf = 1e9; int main() { int n; std::cin >> n; std::vector<std::pair<std::pair<std::string, std::string>, long double>> offers; std::vector<std::pair<std::pair<int, int>, long double>> revised; std::vector<std::string> strings; strings.push_back("blue"); strings.push_back("pink"); for (int i = 0; i < n; ++i) { std::string a, b; long double ratio; std::cin >> a >> b >> ratio; strings.push_back(a); strings.push_back(b); offers.push_back({{a, b}, ratio}); } std::sort(strings.begin(), strings.end()); strings.erase(std::unique(strings.begin(), strings.end()), strings.end()); int m = strings.size(); for (int i = 0; i < offers.size(); ++i) { int low = 0; int high = m - 1; while(low != high) { int mid = (low + high) / 2; if (strings[mid] < offers[i].first.first) { low = mid + 1; } else { high = mid; } } int first = low; low = 0; high = m - 1; while(low != high) { int mid = (low + high) / 2; if (strings[mid] < offers[i].first.second) { low = mid + 1; } else { high = mid; } } int second = low; revised.push_back({{first, second}, offers[i].second}); } int pink = -1; int blue = -1; for (int i = 0; i < m; ++i) { if (strings[i] == "pink") { pink = i; } else if (strings[i] == "blue") { blue = i; } } std::vector<long double> amounts (m); for (int i = 0; i < m; ++i) { amounts[i] = -inf; } amounts[pink] = 0; for (int i = 0; i < revised.size(); ++i) { int o = revised[i].first.first; int w = revised[i].first.second; // std::cout << o << ' ' << w << ' ' << amounts[o] << ' ' << amounts[w] << ' ' << log(revised[i].second) << '\n'; amounts[o] = std::max(amounts[o], amounts[w] + log(revised[i].second)); } /* std::cout << pink << ' ' << blue << '\n'; for (int i = 0; i < m; ++i) { std::cout << amounts[i] << ' '; } std::cout << '\n'; */ if (amounts[blue] > log(10)) { std::cout << 10 << '\n'; } else { std::cout << std::fixed << std::setprecision(20) << exp(amounts[blue]) << '\n'; } }
Test details
Test 1
Verdict: WRONG ANSWER
input |
---|
100 100 1000 0 100 100 100 |
correct output |
---|
2000 |
user output |
---|
0.00000000000000000000 |
Test 2
Verdict: WRONG ANSWER
input |
---|
10 1 1.0 3 1 5 1 |
correct output |
---|
0.628318530717959 |
user output |
---|
0.00000000000000000000 |
Test 3
Verdict: WRONG ANSWER
input |
---|
90 90 1000 0 90 50 89 |
correct output |
---|
1737.04781586106 |
user output |
---|
0.00000000000000000000 |
Test 4
Verdict: WRONG ANSWER
input |
---|
77 100 10.0 10 20 59 40 |
correct output |
---|
5.99839065002337 |
user output |
---|
0.00000000000000000000 |
Test 5
Verdict: WRONG ANSWER
input |
---|
77 100 10.0 10 20 58 40 |
correct output |
---|
5.91679084083922 |
user output |
---|
0.00000000000000000000 |
Test 6
Verdict: WRONG ANSWER
input |
---|
77 100 10.0 10 20 60 40 |
correct output |
---|
6 |
user output |
---|
0.00000000000000000000 |
Test 7
Verdict: WRONG ANSWER
input |
---|
94 89 834.224666298746198 88 58 88 78 |
correct output |
---|
187.466217145786 |
user output |
---|
0.00000000000000000000 |
Test 8
Verdict: WRONG ANSWER
input |
---|
86 58 132.780101674766157 61 15 37 42 |
correct output |
---|
91.9178334394494 |
user output |
---|
0.00000000000000000000 |
Test 9
Verdict: WRONG ANSWER
input |
---|
48 48 949.580203857717765 0 17 22 10 |
correct output |
---|
423.334058520663 |
user output |
---|
0.00000000000000000000 |
Test 10
Verdict: WRONG ANSWER
input |
---|
24 77 800.457601608713411 22 2 2 51 |
correct output |
---|
550.964323185218 |
user output |
---|
0.00000000000000000000 |
Test 11
Verdict: WRONG ANSWER
input |
---|
77 65 15.701332933422467 21 23 2 41 |
correct output |
---|
8.65495113586997 |
user output |
---|
0.00000000000000000000 |
Test 12
Verdict: WRONG ANSWER
input |
---|
27 88 503.951696883614473 20 64 12 41 |
correct output |
---|
350.272388441182 |
user output |
---|
0.00000000000000000000 |
Test 13
Verdict: WRONG ANSWER
input |
---|
20 38 459.104966497621950 8 7 20 19 |
correct output |
---|
304.394918838648 |
user output |
---|
0.00000000000000000000 |
Test 14
Verdict: WRONG ANSWER
input |
---|
78 18 317.374100202220837 11 4 43 18 |
correct output |
---|
337.746592272152 |
user output |
---|
0.00000000000000000000 |
Test 15
Verdict: WRONG ANSWER
input |
---|
70 17 890.350623394215674 14 14 32 11 |
correct output |
---|
622.523687792024 |
user output |
---|
0.00000000000000000000 |
Test 16
Verdict: WRONG ANSWER
input |
---|
86 55 776.267024418476987 68 14 79 37 |
correct output |
---|
404.020771795954 |
user output |
---|
0.00000000000000000000 |
Test 17
Verdict: WRONG ANSWER
input |
---|
75 17 242.793784206116952 68 17 39 6 |
correct output |
---|
261.196052816555 |
user output |
---|
0.00000000000000000000 |
Test 18
Verdict: WRONG ANSWER
input |
---|
26 90 223.974792648645571 4 74 21 20 |
correct output |
---|
233.929227877474 |
user output |
---|
0.00000000000000000000 |
Test 19
Verdict: WRONG ANSWER
input |
---|
91 41 998.270738973855221 32 40 61 8 |
correct output |
---|
974.149964218165 |
user output |
---|
0.00000000000000000000 |
Test 20
Verdict: WRONG ANSWER
input |
---|
68 85 757.685961963360792 43 15 61 25 |
correct output |
---|
200.331908326952 |
user output |
---|
0.00000000000000000000 |
Test 21
Verdict: WRONG ANSWER
input |
---|
65 92 578.920341273201517 59 50 48 84 |
correct output |
---|
381.223494038536 |
user output |
---|
0.00000000000000000000 |
Test 22
Verdict: WRONG ANSWER
input |
---|
33 77 790.247938932401860 20 39 7 13 |
correct output |
---|
431.95529507812 |
user output |
---|
0.00000000000000000000 |
Test 23
Verdict: WRONG ANSWER
input |
---|
9 61 482.495860237616059 9 5 8 13 |
correct output |
---|
77.0832954219641 |
user output |
---|
0.00000000000000000000 |
Test 24
Verdict: WRONG ANSWER
input |
---|
75 13 742.153102644523069 19 11 20 11 |
correct output |
---|
26.3045847037702 |
user output |
---|
0.00000000000000000000 |
Test 25
Verdict: WRONG ANSWER
input |
---|
20 17 261.780654789729291 10 5 12 1 |
correct output |
---|
66.4331433736971 |
user output |
---|
0.00000000000000000000 |
Test 26
Verdict: WRONG ANSWER
input |
---|
28 21 156.969628799131283 24 6 13 21 |
correct output |
---|
167.473009952367 |
user output |
---|
0.00000000000000000000 |
Test 27
Verdict: WRONG ANSWER
input |
---|
78 31 310.031404611738786 16 3 10 9 |
correct output |
---|
67.2566419579323 |
user output |
---|
0.00000000000000000000 |
Test 28
Verdict: WRONG ANSWER
input |
---|
47 29 895.835934748884703 38 29 41 20 |
correct output |
---|
401.907333737717 |
user output |
---|
0.00000000000000000000 |
Test 29
Verdict: WRONG ANSWER
input |
---|
77 48 10.034875183687164 5 30 28 18 |
correct output |
---|
6.03998311542924 |
user output |
---|
0.00000000000000000000 |
Test 30
Verdict: WRONG ANSWER
input |
---|
63 6 130.738644075830671 45 5 4 4 |
correct output |
---|
196.107966113746 |
user output |
---|
0.00000000000000000000 |