QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#95428 | #5133. Imperfect Imperial Units | _b_ | WA | 0ms | 3596kb | C++14 | 1.3kb | 2023-04-09 17:25:43 | 2023-04-09 17:25:48 |
Judging History
answer
#include<iostream>
#include<map>
#include<utility>
#include<vector>
#include<iomanip>
using namespace std;
#define ld long double
map<pair<string,string>, ld>convert;
map<pair<string, string>, int>book;
vector<string>tol;
int n, q;
int main() {
cin >> n >> q;
ld tmp1, tmp2; string s1, s2; string trash;
for (int i = 0; i < n; i++) {
cin >> tmp1 >> s1 >> trash >> tmp2 >> s2;
convert[{s1, s2}] = tmp2 / tmp1; convert[{s2, s1}] = tmp1 / tmp2;
book[{s1, s2}] = 1; book[{s2, s1}] = 1;
for (auto& s : tol) {
if (s != s1 && s != s2) {
if (book[{s, s1}]) {
book[{s, s2}] = 1; book[{s2, s}] = 1;
convert[{s, s2}] = convert[{s, s1}] * convert[{s1, s2}];
convert[{s2, s}] = convert[{s2, s1}] * convert[{s1, s}];
}
else if (book[{s, s2}]) {
book[{s, s1}] = 1; book[{s1, s1}] = 1;
convert[{s, s1}] = convert[{s, s2}] * convert[{s2, s1}];
convert[{s1, s}] = convert[{s1, s2}] * convert[{s2, s}];
}
}
}
tol.push_back(s1); tol.push_back(s2);
}
ld target;
for (int i = 0; i < q; i++) {
cin >> target >> s1 >> trash >> s2;
ld ans = target * convert[{s1, s2}];
if (book[{s1,s2}]==0) {
cout << "impossible" << endl;
}
else {
cout << setprecision(18) << ans << endl;
}
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3596kb
input:
4 3 1 foot = 12 inch 1 yard = 3 foot 1 meter = 100 centimeter 1 centimeter = 10 millimeter 750 millimeter to meter 42 yard to inch 10 meter to foot
output:
0.75 impossible impossible
result:
wrong answer