QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#131848 | #5133. Imperfect Imperial Units | Yarema# | WA | 276ms | 3900kb | C++17 | 1.3kb | 2023-07-28 15:51:39 | 2023-07-28 15:51:42 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define FOR(i, a, b) for (int i = (a); i<(b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i>=(a); --i)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define FILL(a, b) memset(a, b, sizeof(a))
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
const int INF = 1e9 + 7;
const int N = 447;
map<string, int> m;
vector<pair<int, __float128>> g[N];
__float128 val[N];
bool used[N];
void dfs(int v, __float128 a)
{
used[v] = 1;
val[v] = a;
for (auto& [to, d] : g[v])
if (!used[to])
dfs(to, a * d);
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int idx = 0;
int n, q;
cin >> n >> q;
FOR (i, 0, n)
{
string s, t;
long double d;
cin >> s >> s >> t >> d >> t;
if (!m.count(s))
m[s] = idx++;
if (!m.count(t))
m[t] = idx++;
g[m[s]].PB({m[t], d});
g[m[t]].PB({m[s], 1 / d});
}
cout << fixed << setprecision(300);
FOR (i, 0, q)
{
long double x;
string s, t;
cin >> x >> s >> t >> t;
int v = m[s];
dfs(v, x);
if (val[m[t]] < -1)
cout << "impossible\n";
else
cout << (long double)val[m[t]] << '\n';
FOR (j, 0, SZ(m))
{
used[j] = 0;
val[j] = -2;
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3788kb
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.7500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
ok
Test #2:
score: 0
Accepted
time: 1ms
memory: 3688kb
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.2464065708427369827404618263244628906250000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
ok
Test #3:
score: 0
Accepted
time: 1ms
memory: 3696kb
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.0000000000000000044394035029033849474005178794794160721119496874077861049961296613375338893092703074216842651367187500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
ok
Test #4:
score: 0
Accepted
time: 81ms
memory: 3892kb
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:
7540565404.5878788223490118980407714843750000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
ok
Test #5:
score: 0
Accepted
time: 1ms
memory: 3772kb
input:
5 42 1 ooooooooooooooooooll = 142.885328495 oooooooooooooooooloo 1 oooooooooooooooooolo = 890.325815433 ooooooooooooooooooll 1 oooooooooooooooooolo = 981.374056267 oooooooooooooooooool 1 ooooooooooooooooolol = 852.547129907 oooooooooooooooooloo 1 ooooooooooooooooooll = 723.801234729 oooooooooooooooo...
output:
57945237.740397935289365705102682113647460937500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
ok
Test #6:
score: 0
Accepted
time: 1ms
memory: 3700kb
input:
5 42 1 oooooooooooooooooooo = 732.078459045 oooooooooooooooooolo 1 ooooooooooooooooolol = 844.175222640 oooooooooooooooooolo 1 oooooooooooooooooool = 997.155262893 ooooooooooooooooooll 1 oooooooooooooooooloo = 645.410166331 ooooooooooooooooolol 1 ooooooooooooooooooll = 485.989361539 oooooooooooooooo...
output:
0.0024363574309401472516486953333314513514551435946486890316009521484375000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
ok
Test #7:
score: 0
Accepted
time: 91ms
memory: 3708kb
input:
100 10000 1 oooooooooooooooooooo = 100.473080734 oooooooooooooooooool 1 oooooooooooooooooool = 161.954929534 oooooooooooooooooolo 1 oooooooooooooooooolo = 231.933887741 ooooooooooooooooooll 1 ooooooooooooooooooll = 481.662840068 oooooooooooooooooloo 1 oooooooooooooooooloo = 566.369884850 ooooooooooo...
output:
5583007873719478945471962605109356943148853226264068096.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
ok
Test #8:
score: 0
Accepted
time: 98ms
memory: 3716kb
input:
100 10000 1 oooooooooooooooooooo = 667.152266248 oooooooooooooooooool 1 oooooooooooooooooool = 275.388730431 oooooooooooooooooolo 1 oooooooooooooooooolo = 850.056569929 ooooooooooooooooooll 1 ooooooooooooooooooll = 968.012584255 oooooooooooooooooloo 1 oooooooooooooooooloo = 602.896729977 ooooooooooo...
output:
102257618718385980628992.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
ok
Test #9:
score: 0
Accepted
time: 101ms
memory: 3836kb
input:
100 10000 1 oooooooooooooooooooo = 119.902630504 oooooooooooooooooool 1 oooooooooooooooooool = 317.399001691 oooooooooooooooooolo 1 oooooooooooooooooolo = 29.526873476 ooooooooooooooooooll 1 ooooooooooooooooooll = 226.003375174 oooooooooooooooooloo 1 oooooooooooooooooloo = 977.948345504 oooooooooooo...
output:
6003779053228542274841039278472677031936.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
ok
Test #10:
score: 0
Accepted
time: 7ms
memory: 3776kb
input:
42 1337 1 oooooooooooooooooooo = 835.161633070 oooooooooooooooooool 1 oooooooooooooooooool = 628.032987858 oooooooooooooooooolo 1 oooooooooooooooooolo = 613.458608316 ooooooooooooooooooll 1 ooooooooooooooooooll = 669.609173844 oooooooooooooooooloo 1 oooooooooooooooooloo = 192.692866236 ooooooooooooo...
output:
12195814801254158672380572336115227595365750407168.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
ok
Test #11:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
5 42 1 oooooooooooooooooooo = 415.717707048 oooooooooooooooooool 1 oooooooooooooooooool = 567.879837190 oooooooooooooooooolo 1 oooooooooooooooooolo = 247.709598786 ooooooooooooooooooll 1 ooooooooooooooooooll = 844.646506012 oooooooooooooooooloo 1 oooooooooooooooooloo = 125.341351424 oooooooooooooooo...
output:
0.7064386677620646381309255090741316962521523237228393554687500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
ok
Test #12:
score: 0
Accepted
time: 65ms
memory: 3900kb
input:
100 10000 1 oooooooooooooooooooo = 0.001000000 oooooooooooooooooool 1 oooooooooooooooooool = 0.001000000 oooooooooooooooooolo 1 oooooooooooooooooolo = 0.001000000 ooooooooooooooooooll 1 ooooooooooooooooooll = 0.001000000 oooooooooooooooooloo 1 oooooooooooooooooloo = 0.001000000 ooooooooooooooooolol ...
output:
0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
ok
Test #13:
score: 0
Accepted
time: 53ms
memory: 3708kb
input:
100 10000 1 oooooooooooooooooooo = 0.001111111 oooooooooooooooooool 1 oooooooooooooooooool = 0.001111111 oooooooooooooooooolo 1 oooooooooooooooooolo = 0.001111111 ooooooooooooooooooll 1 ooooooooooooooooooll = 0.001111111 oooooooooooooooooloo 1 oooooooooooooooooloo = 0.001111111 ooooooooooooooooolol ...
output:
0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
ok
Test #14:
score: 0
Accepted
time: 73ms
memory: 3892kb
input:
100 10000 1 oooooooooooooooooooo = 0.100000000 oooooooooooooooooool 1 oooooooooooooooooool = 0.100000000 oooooooooooooooooolo 1 oooooooooooooooooolo = 0.100000000 ooooooooooooooooooll 1 ooooooooooooooooooll = 0.100000000 oooooooooooooooooloo 1 oooooooooooooooooloo = 0.100000000 ooooooooooooooooolol ...
output:
0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000137247787600736136393866950369337973706498913056600921799037924563372248695961887052296989240702566886458760616342777409297345463560604329132497795373740877717721634064836856632524...
result:
ok
Test #15:
score: 0
Accepted
time: 63ms
memory: 3816kb
input:
100 10000 1 oooooooooooooooooooo = 1.000000000 oooooooooooooooooool 1 oooooooooooooooooool = 1.000000000 oooooooooooooooooolo 1 oooooooooooooooooolo = 1.000000000 ooooooooooooooooooll 1 ooooooooooooooooooll = 1.000000000 oooooooooooooooooloo 1 oooooooooooooooooloo = 1.000000000 ooooooooooooooooolol ...
output:
1.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
ok
Test #16:
score: 0
Accepted
time: 109ms
memory: 3820kb
input:
100 10000 1 oooooooooooooooooooo = 10.000000000 oooooooooooooooooool 1 oooooooooooooooooool = 10.000000000 oooooooooooooooooolo 1 oooooooooooooooooolo = 10.000000000 ooooooooooooooooooll 1 ooooooooooooooooooll = 10.000000000 oooooooooooooooooloo 1 oooooooooooooooooloo = 10.000000000 oooooooooooooooo...
output:
99999999999999999996693535322073426194986990198284960792713915417520186694826443244189778401170554880.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
ok
Test #17:
score: 0
Accepted
time: 246ms
memory: 3704kb
input:
100 10000 1 oooooooooooooooooooo = 1000.000000000 oooooooooooooooooool 1 oooooooooooooooooool = 1000.000000000 oooooooooooooooooolo 1 oooooooooooooooooolo = 1000.000000000 ooooooooooooooooooll 1 ooooooooooooooooooll = 1000.000000000 oooooooooooooooooloo 1 oooooooooooooooooloo = 1000.000000000 oooooo...
output:
100000000000000000001306338593867813193286239641666938228236899693517805332016156193366617731817347789926294211856470235704757344154848189459793301705153549783206768801204551359895956599945453988253868608426068842563750792196190750588312338999097538263366619451242651251292344694091626418654258738180...
result:
ok
Test #18:
score: 0
Accepted
time: 82ms
memory: 3812kb
input:
100 10000 1 oooooooooooooooooooo = 4.200000000 oooooooooooooooooool 1 oooooooooooooooooool = 4.200000000 oooooooooooooooooolo 1 oooooooooooooooooolo = 4.200000000 ooooooooooooooooooll 1 ooooooooooooooooooll = 4.200000000 oooooooooooooooooloo 1 oooooooooooooooooloo = 4.200000000 ooooooooooooooooolol ...
output:
887520371224771505660930051115048130581194377754120552263450624.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
ok
Test #19:
score: 0
Accepted
time: 276ms
memory: 3892kb
input:
100 10000 1 oooooooooooooooooooo = 999.999999999 oooooooooooooooooool 1 oooooooooooooooooool = 999.999999999 oooooooooooooooooolo 1 oooooooooooooooooolo = 999.999999999 ooooooooooooooooooll 1 ooooooooooooooooooll = 999.999999999 oooooooooooooooooloo 1 oooooooooooooooooloo = 999.999999999 ooooooooooo...
output:
999999999898999997279922326570318807142467157678880773235090880648930534688177321120135710857609483518823486026142218423794770297515187605081064932038928209171201041997183216313045661415475081454904544969365286869257424259937250890451780512701849662128768218116521325954244827780938085418947150438465...
result:
ok
Test #20:
score: 0
Accepted
time: 110ms
memory: 3896kb
input:
100 10000 1 oooooooooooooooooooo = 9.999999999 oooooooooooooooooool 1 oooooooooooooooooool = 9.999999999 oooooooooooooooooolo 1 oooooooooooooooooolo = 9.999999999 ooooooooooooooooooll 1 ooooooooooooooooooll = 9.999999999 oooooooooooooooooloo 1 oooooooooooooooooloo = 9.999999999 ooooooooooooooooolol ...
output:
99999998990000004703760194837458282425585003360889281090156809791954306223437356096465459080102674432.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
ok
Test #21:
score: 0
Accepted
time: 0ms
memory: 3692kb
input:
1 1 1 a = 0.001 b 0.001 a to b
output:
0.000000999999999999999999932852786595395425464638528012528695398941636085510253906250000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
result:
ok
Test #22:
score: 0
Accepted
time: 1ms
memory: 3684kb
input:
1 1 1 a = 1 b 1 a to b
output:
1.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
result:
ok
Test #23:
score: 0
Accepted
time: 1ms
memory: 3784kb
input:
1 1 1 a = 1 b 1 a to a
output:
1.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
result:
ok
Test #24:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
1 1 1 a = 1000 b 1000 a to b
output:
1000000.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
result:
ok
Test #25:
score: -100
Wrong Answer
time: 1ms
memory: 3812kb
input:
2 1 1 a = 1 b 1 c = 1 d 1 a to d
output:
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
result:
wrong answer