QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#131843 | #5133. Imperfect Imperial Units | Yarema# | WA | 224ms | 3896kb | C++17 | 1.3kb | 2023-07-28 15:44:54 | 2023-07-28 15:44:56 |
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, long double>> g[N];
long double val[N];
bool used[N];
void dfs(int v, long double 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(20);
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 << val[m[t]] << '\n';
FOR (j, 0, SZ(m))
{
used[j] = 0;
val[j] = -2;
}
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3784kb
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.75000000000000000000 1512.00000000000000000000 impossible
result:
ok
Test #2:
score: 0
Accepted
time: 1ms
memory: 3816kb
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.24640657084273698274 0.00001304464285714286 0.22428571428571428572
result:
ok
Test #3:
score: 0
Accepted
time: 0ms
memory: 3688kb
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.00000000000000000444 397350679848393599968.00000000000000000000
result:
ok
Test #4:
score: 0
Accepted
time: 19ms
memory: 3896kb
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.58787882281467318535 0.00000000000748033346 6.21272970725337681961 107.44657978777485983490 537.47666997595315091507 0.00000048084335782072 2.50069201679817434362 43554794.10149038458257564344 436.99125377811471168665 16358985539.02281655278056859970 0.00000608918103660328 70214.207950533...
result:
ok
Test #5:
score: 0
Accepted
time: 1ms
memory: 3672kb
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.74039793528936570510 2.59628194566664064662 3025.85357931461301839171 3.72800373838378387823 0.21752362642334863394 92614.93379111134434822361 1984.85291133861365420188 1.14994858839527759446 348149.67872930574009160409 152.23604417699999999392 37.11773324514713965488 133614.050988509591846...
result:
ok
Test #6:
score: 0
Accepted
time: 0ms
memory: 3872kb
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.00243635743094014725 337732353609.35413113236427307129 68.06821573699999999851 0.00166871625293380942 330638221.67121047771070152521 1.00206988440567528766 0.59728995663112576236 0.40325721894090594774 607366.87277380277572547129 0.00047879537011872882 0.11220378037221767079 544.208521467000000015...
result:
ok
Test #7:
score: 0
Accepted
time: 42ms
memory: 3796kb
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:
5583007873719478946136576603001814879600756756404240384.00000000000000000000 5197237613376014437317884601573976479017106056328075936435411381463855910570023915607536989165828281475817527290128699536666352010759245704200192.00000000000000000000 0.00000000000000000000 106482.11745552721563257137 0.000...
result:
ok
Test #8:
score: 0
Accepted
time: 47ms
memory: 3892kb
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:
102257618718385980637184.00000000000000000000 95.48632020599999999794 39768869204462313677377398001446890074789008396189872529866752.00000000000000000000 0.00000000000000000000 823476884112028142266846107729521523130471583994828982365143047891159422356782259428641345750698522163548356909735092385159...
result:
ok
Test #9:
score: 0
Accepted
time: 39ms
memory: 3760kb
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:
6003779053228542274250743468113971380224.00000000000000000000 0.00000000000000000000 695538424085371148316952643892872525243565034249696633271011545266017974585963538903177435142167380430084918040245699608576.00000000000000000000 12851529262049411084991672090624.00000000000000000000 3941187549762279...
result:
ok
Test #10:
score: 0
Accepted
time: 5ms
memory: 3688kb
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.00000000000000000000 418026513377835311296.00000000000000000000 0.00000000000000000000 1094040559263045529984.00000000000000000000 2293451817426239520569372632761569218819784704.00000000000000000000 0.00000000000000000008 0.00000000000000000000 3194...
result:
ok
Test #11:
score: 0
Accepted
time: 1ms
memory: 3800kb
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.70643866776206463813 4.74364484422778071113 122341371.16824106707645114511 26184240520308.74797058105468750000 14753088366.58369748480618000031 4119859148495226.70263671875000000000 0.00611128203335813162 61982716.14699366278364323080 43257572.87203543775831349194 0.00000001852141950098 0.69515726...
result:
ok
Test #12:
score: 0
Accepted
time: 15ms
memory: 3708kb
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.00000000000000000000 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 0...
result:
ok
Test #13:
score: 0
Accepted
time: 19ms
memory: 3784kb
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.00000000000000000000 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 0...
result:
ok
Test #14:
score: 0
Accepted
time: 15ms
memory: 3836kb
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.00000000000000000000 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 0...
result:
ok
Test #15:
score: 0
Accepted
time: 20ms
memory: 3892kb
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.00000000000000000000 1.00000000000000000000 1.00000000000000000000 1.00000000000000000000 1.00000000000000000000 1.00000000000000000000 1.00000000000000000000 1.00000000000000000000 1.00000000000000000000 1.00000000000000000000 1.00000000000000000000 1.00000000000000000000 1.00000000000000000000 1...
result:
ok
Test #16:
score: 0
Accepted
time: 64ms
memory: 3704kb
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:
100000000000000000004282085682330180378266138271814331521785817132567606699716335469732373265253400576.00000000000000000000 100000000000000000004282085682330180378266138271814331521785817132567606699716335469732373265253400576.00000000000000000000 1000000000000000000042820856823301803782661382718143...
result:
ok
Test #17:
score: 0
Accepted
time: 212ms
memory: 3828kb
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:
999999999999999999790010849667010672513153021694184298262679966686268884461795783036275078744112821867487694944141249768577764873019535937029745230219799641663443100846686319731513939932335558791135724609116027895101628554609191924972961083959293369410101353460127800061116681122794677262977785059606...
result:
ok
Test #18:
score: 0
Accepted
time: 48ms
memory: 3828kb
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:
887520371224771505482524089526803145448908631572933660215607296.00000000000000000000 887520371224771505482524089526803145448908631572933660215607296.00000000000000000000 887520371224771505482524089526803145448908631572933660215607296.00000000000000000000 887520371224771505482524089526803145448908631...
result:
ok
Test #19:
score: 0
Accepted
time: 224ms
memory: 3888kb
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:
999999999898999997428624017418097113422273407493870829248216900814869980593754507051729776573649920873340317475757853482774642676534484910126523456593418779950284100107422678891342745460221068849173185952795060556281343838172394611058555383389637670944478112151387134255449338326352476701323685319933...
result:
ok
Test #20:
score: 0
Accepted
time: 70ms
memory: 3780kb
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:
99999998990000004718937295557971790792143299507948022548300613222049146233217140547550648808268365824.00000000000000000000 99999998990000004718937295557971790792143299507948022548300613222049146233217140547550648808268365824.00000000000000000000 999999989900000047189372955579717907921432995079480225...
result:
ok
Test #21:
score: 0
Accepted
time: 1ms
memory: 3684kb
input:
1 1 1 a = 0.001 b 0.001 a to b
output:
0.00000100000000000000
result:
ok
Test #22:
score: 0
Accepted
time: 1ms
memory: 3792kb
input:
1 1 1 a = 1 b 1 a to b
output:
1.00000000000000000000
result:
ok
Test #23:
score: 0
Accepted
time: 1ms
memory: 3760kb
input:
1 1 1 a = 1 b 1 a to a
output:
1.00000000000000000000
result:
ok
Test #24:
score: 0
Accepted
time: 1ms
memory: 3864kb
input:
1 1 1 a = 1000 b 1000 a to b
output:
1000000.00000000000000000000
result:
ok
Test #25:
score: -100
Wrong Answer
time: 0ms
memory: 3740kb
input:
2 1 1 a = 1 b 1 c = 1 d 1 a to d
output:
0.00000000000000000000
result:
wrong answer