QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#397612 | #5133. Imperfect Imperial Units | ucup-team1001# | WA | 30ms | 4404kb | C++23 | 2.0kb | 2024-04-24 14:37:31 | 2024-04-24 14:37:33 |
Judging History
answer
/*
Author: Haze
2024/4/24
*/
#include <bits/stdc++.h>
#define irep(i, l, r) for(int i = (l); i <= (r); ++ i)
#define drep(i, r, l) for(int i = (r); i >= (l); -- i)
#define IOS ios::sync_with_stdio(false), cin.tie(nullptr);
using namespace std;
typedef long long ll;
inline ll read() {
ll s = 0;
bool fl = false;
char ch = (char) getchar();
while (!isdigit(ch)) {
if (ch == '-')fl = true;
ch = (char) getchar();
}
while (isdigit(ch)) {
s = s * 10 + (ch ^ 48);
ch = (char) getchar();
}
return fl ? -s : s;
}
const int mod = 1000000000 + 7;
const int itinf = 1000000999;
const ll llinf = 2e18;
const int N = 500099;
void solve() {
int n, q;
cin >> n >> q;
vector<vector<long double>> dis(2 * n + 2, vector<long double>(2 * n + 2, -1));
map<string, int> ma;
int cnt = 0;
for(int i = 0; i < n; i++) {
long double x, y;
string s1, s2;
cin >> x >> s1;
cin >> s2;
cin >> y >> s2;
if(!ma[s1]) {
ma[s1] = ++ cnt;
}
if(!ma[s2]) {
ma[s2] = ++ cnt;
}
dis[ma[s1]][ma[s2]] = y / x;
dis[ma[s2]][ma[s1]] = x / y;
}
for(int i = 1; i <= cnt; i++)
dis[i][i] = 1;
for(int k = 1; k <= cnt; k++)
for(int i = 1; i <= cnt; i++) {
for(int j = 1; j <= cnt; j++) {
if(dis[i][k] == -1 || dis[k][j] == -1)
continue;
else
dis[i][j] = dis[i][k] * dis[k][j];
}
}
while(q--) {
long double x;
string s1, s2;
cin >> x;
cin >> s1 >> s2;
cin >> s2;
if(dis[ma[s1]][ma[s2]] == -1) {
cout << "impossible" << endl;
}
else {
printf("%.40Lf\n", x * dis[ma[s1]][ma[s2]]);
}
}
}
int main() {
//IOS
int T = 1;
while (T--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3992kb
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.7499999999999999999457898913757247782996 1512.0000000000000000000000000000000000000000 impossible
result:
ok
Test #2:
score: 0
Accepted
time: 0ms
memory: 4000kb
input:
4 3 1 fortnight = 14 day 1 microcentury = 0.036525 day 1 microcentury = 1000 nanocentury 1 week = 7 day 22.2 fortnight to nanocentury 2.5 nanocentury to week 3.14 day to fortnight
output:
8509240.2464065708400084986351430416107177734375 0.0000130446428571428571378517907251978671 0.2242857142857142856552741388975746872347
result:
ok
Test #3:
score: 0
Accepted
time: 1ms
memory: 4000kb
input:
10 2 1 micrometer = 1000 nanometer 1 millimeter = 1000 micrometer 1 meter = 1000 millimeter 1 kilometer = 1000 meter 1 megameter = 1000 kilometer 1 lightsecond = 299.792458 meter 1 lightminute = 60 lightsecond 1 lighthour = 60 lightminute 1 lightday = 24 lighthour 1 lightyear = 365.25 lightday 42 na...
output:
0.0000000000000000044394035029032009594009 397350679848377132000.0000000000000000000000000000000000000000
result:
ok
Test #4:
score: -100
Wrong Answer
time: 30ms
memory: 4404kb
input:
100 10000 1 ooooooooooooooooolol = 913.613760987 ooooooooooooolooooll 1 oooooooooooooloollol = 626.088582061 ooooooooooooololooll 1 oooooooooooooolololo = 955.470952951 oooooooooooooloolooo 1 oooooooooooooooooool = 942.991120183 oooooooooooooooloolo 1 oooooooooooooooloooo = 537.689261619 ooooooooooo...
output:
0.0000000000000000000000000000000000000000 0.0000000000000000000000000000000000000000 0.0000000000000000000000000000000000000000 0.0000000000000000000000000000000000000000 0.0000000000000000000000000000000000000000 0.0000000000000000000000000000000000000000 0.0000000000000000000000000000000000000000...
result:
wrong answer