QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#131842 | #5133. Imperfect Imperial Units | Yarema# | WA | 224ms | 3896kb | C++17 | 1.3kb | 2023-07-28 15:44:32 | 2023-07-28 15:44:35 |
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(25);
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: 1ms
memory: 3648kb
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.7500000000000000000000000 1512.0000000000000000000000000 impossible
result:
ok
Test #2:
score: 0
Accepted
time: 0ms
memory: 3740kb
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.2464065708427369827404618 0.0000130446428571428571420 0.2242857142857142857230368
result:
ok
Test #3:
score: 0
Accepted
time: 1ms
memory: 3872kb
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.0000000000000000044394035 397350679848393599968.0000000000000000000000000
result:
ok
Test #4:
score: 0
Accepted
time: 21ms
memory: 3700kb
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.5878788228146731853485107 0.0000000000074803334603849 6.2127297072533768196138382 107.4465797877748598349034737 537.4766699759531509150711770 0.0000004808433578207225601 2.5006920167981743436183550 43554794.1014903845825756434351206 436.9912537781147116866531377 16358985539.02281655278056...
result:
ok
Test #5:
score: 0
Accepted
time: 1ms
memory: 3692kb
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.7403979352893657051026821 2.5962819456666406466201213 3025.8535793146130183917108525 3.7280037383837838782258550 0.2175236264233486339350013 92614.9337911113443482236107229 1984.8529113386136542018789441 1.1499485883952775944595939 348149.6787293057400916040933225 152.2360441769999999939155...
result:
ok
Test #6:
score: 0
Accepted
time: 1ms
memory: 3772kb
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.0024363574309401472516487 337732353609.3541311323642730712890625 68.0682157369999999985132888 0.0016687162529338094161959 330638221.6712104777107015252113342 1.0020698844056752876583924 0.5972899566311257623556566 0.4032572189409059477353120 607366.8727738027757254712923896 0.000478795370118728821...
result:
ok
Test #7:
score: 0
Accepted
time: 48ms
memory: 3896kb
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.0000000000000000000000000 5197237613376014437317884601573976479017106056328075936435411381463855910570023915607536989165828281475817527290128699536666352010759245704200192.0000000000000000000000000 0.0000000000000000000000000 106482.11745552721...
result:
ok
Test #8:
score: 0
Accepted
time: 39ms
memory: 3896kb
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.0000000000000000000000000 95.4863202059999999979367225 39768869204462313677377398001446890074789008396189872529866752.0000000000000000000000000 0.0000000000000000000000069 8234768841120281422668461077295215231304715839948289823651430478911594223567822594286413457506985221635...
result:
ok
Test #9:
score: 0
Accepted
time: 47ms
memory: 3888kb
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.0000000000000000000000000 0.0000000000000000000000000 695538424085371148316952643892872525243565034249696633271011545266017974585963538903177435142167380430084918040245699608576.0000000000000000000000000 12851529262049411084991672090624.0000000000000000000000...
result:
ok
Test #10:
score: 0
Accepted
time: 5ms
memory: 3816kb
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.0000000000000000000000000 418026513377835311296.0000000000000000000000000 0.0000000000000000000000000 1094040559263045529984.0000000000000000000000000 2293451817426239520569372632761569218819784704.0000000000000000000000000 0.00000000000000000008014...
result:
ok
Test #11:
score: 0
Accepted
time: 0ms
memory: 3764kb
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.7064386677620646381309255 4.7436448442277807111336352 122341371.1682410670764511451125145 26184240520308.7479705810546875000000000 14753088366.5836974848061800003051758 4119859148495226.7026367187500000000000000 0.0061112820333581316161272 61982716.1469936627836432307958603 43257572.87203543775831...
result:
ok
Test #12:
score: 0
Accepted
time: 14ms
memory: 3784kb
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.0000000000000000000000000 0.0000000000000000000000000 0.0000000000000000000000000 0.0000000000000000000000000 0.0000000000000000000000000 0.0000000000000000000000000 0.0000000000000000000000000 0.0000000000000000000000000 0.0000000000000000000000000 0.0000000000000000000000000 0.000000000000000000...
result:
ok
Test #13:
score: 0
Accepted
time: 22ms
memory: 3812kb
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.0000000000000000000000000 0.0000000000000000000000000 0.0000000000000000000000000 0.0000000000000000000000000 0.0000000000000000000000000 0.0000000000000000000000000 0.0000000000000000000000000 0.0000000000000000000000000 0.0000000000000000000000000 0.0000000000000000000000000 0.000000000000000000...
result:
ok
Test #14:
score: 0
Accepted
time: 17ms
memory: 3784kb
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.0000000000000000000000000 0.0000000000000000000000000 0.0000000000000000000000000 0.0000000000000000000000000 0.0000000000000000000000000 0.0000000000000000000000000 0.0000000000000000000000000 0.0000000000000000000000000 0.0000000000000000000000000 0.0000000000000000000000000 0.000000000000000000...
result:
ok
Test #15:
score: 0
Accepted
time: 12ms
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.0000000000000000000000000 1.0000000000000000000000000 1.0000000000000000000000000 1.0000000000000000000000000 1.0000000000000000000000000 1.0000000000000000000000000 1.0000000000000000000000000 1.0000000000000000000000000 1.0000000000000000000000000 1.0000000000000000000000000 1.000000000000000000...
result:
ok
Test #16:
score: 0
Accepted
time: 64ms
memory: 3840kb
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.0000000000000000000000000 100000000000000000004282085682330180378266138271814331521785817132567606699716335469732373265253400576.0000000000000000000000000 100000000000000000004282085682330180378266...
result:
ok
Test #17:
score: 0
Accepted
time: 224ms
memory: 3892kb
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: 47ms
memory: 3888kb
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.0000000000000000000000000 887520371224771505482524089526803145448908631572933660215607296.0000000000000000000000000 887520371224771505482524089526803145448908631572933660215607296.0000000000000000000000000 887520371224771505482524089526...
result:
ok
Test #19:
score: 0
Accepted
time: 222ms
memory: 3896kb
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: 63ms
memory: 3760kb
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.0000000000000000000000000 99999998990000004718937295557971790792143299507948022548300613222049146233217140547550648808268365824.0000000000000000000000000 99999998990000004718937295557971790792143299...
result:
ok
Test #21:
score: 0
Accepted
time: 1ms
memory: 3868kb
input:
1 1 1 a = 0.001 b 0.001 a to b
output:
0.0000009999999999999999999
result:
ok
Test #22:
score: 0
Accepted
time: 0ms
memory: 3780kb
input:
1 1 1 a = 1 b 1 a to b
output:
1.0000000000000000000000000
result:
ok
Test #23:
score: 0
Accepted
time: 1ms
memory: 3868kb
input:
1 1 1 a = 1 b 1 a to a
output:
1.0000000000000000000000000
result:
ok
Test #24:
score: 0
Accepted
time: 1ms
memory: 3680kb
input:
1 1 1 a = 1000 b 1000 a to b
output:
1000000.0000000000000000000000000
result:
ok
Test #25:
score: -100
Wrong Answer
time: 1ms
memory: 3872kb
input:
2 1 1 a = 1 b 1 c = 1 d 1 a to d
output:
0.0000000000000000000000000
result:
wrong answer