QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#131844#5133. Imperfect Imperial UnitsYarema#WA 238ms3900kbC++171.3kb2023-07-28 15:46:522023-07-28 15:46:53

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-28 15:46:53]
  • 评测
  • 测评结果:WA
  • 用时:238ms
  • 内存:3900kb
  • [2023-07-28 15:46:52]
  • 提交

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(30);
	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;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3764kb

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.750000000000000000000000000000
1512.000000000000000000000000000000
impossible

result:

ok 

Test #2:

score: 0
Accepted
time: 1ms
memory: 3796kb

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.246406570842736982740461826324
0.000013044642857142857141987694
0.224285714285714285723036774678

result:

ok 

Test #3:

score: 0
Accepted
time: 1ms
memory: 3820kb

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.000000000000000004439403502903
397350679848393600000.000000000000000000000000000000

result:

ok 

Test #4:

score: 0
Accepted
time: 40ms
memory: 3776kb

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.587878822349011898040771484375
0.000000000007480333460384883444
6.212729707253376819613838177858
107.446579787774859834903473654322
537.476669975953150859560025764949
0.000000480843357820722560144696
2.500692016798174343401514607699
43554794.101490384582575643435120582581
436.991253778114...

result:

ok 

Test #5:

score: 0
Accepted
time: 1ms
memory: 3880kb

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.740397935289365705102682113647
2.596281945666640646620121346544
3025.853579314613018391710852483811
3.728003738383783878225855024091
0.217523626423348633935001342210
92614.933791111344348223610722925514
1984.852911338613654201878944149939
1.149948588395277594459593928367
348149.678729305740...

result:

ok 

Test #6:

score: 0
Accepted
time: 0ms
memory: 3692kb

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.002436357430940147251648695333
337732353609.354131132364273071289062500000
68.068215736999999998513288801405
0.001668716252933809416089996067
330638221.671210477710701525211334228516
1.002069884405675287658392391688
0.597289956631125762355656594327
0.403257218940905947735311998237
607366.872773802...

result:

ok 

Test #7:

score: 0
Accepted
time: 61ms
memory: 3820kb

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.000000000000000000000000000000
5197237613376014436302502633512154631026964143189739619258981788430719957748803366066049693826854054288326900054726022010766250340323367348862976.000000000000000000000000000000
0.000000000000000000000000000000
106...

result:

ok 

Test #8:

score: 0
Accepted
time: 59ms
memory: 3712kb

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.000000000000000000000000000000
95.486320205999999997936722451186
39768869204462313680164991151263217967480973180270917718114304.000000000000000000000000000000
0.000000000000000000000006860626
82347688411202814226684610772952152313047158399482898236514304789115942235678225942...

result:

ok 

Test #9:

score: 0
Accepted
time: 60ms
memory: 3764kb

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.000000000000000000000000000000
0.000000000000000000000000000000
695538424085371148245280812143182790505726881271506416371118889354509189469163887672336095264402230177896838255554271903744.000000000000000000000000000000
12851529262049411084991672090624.0000000...

result:

ok 

Test #10:

score: 0
Accepted
time: 6ms
memory: 3884kb

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.000000000000000000000000000000
418026513377835311264.000000000000000000000000000000
0.000000000000000000000000000000
1094040559263045529920.000000000000000000000000000000
2293451817426239520259887622940224150095003648.000000000000000000000000000000
...

result:

ok 

Test #11:

score: 0
Accepted
time: 0ms
memory: 3880kb

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.706438667762064638130925509074
4.743644844227780711133635183074
122341371.168241067076451145112514495850
26184240520308.747972488403320312500000000000
14753088366.583697484806180000305175781250
4119859148495226.702636718750000000000000000000
0.006111282033358131615703717895
61982716.14699366278364...

result:

ok 

Test #12:

score: 0
Accepted
time: 35ms
memory: 3808kb

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.000000000000000000000000000000
0.000000000000000000000000000000
0.000000000000000000000000000000
0.000000000000000000000000000000
0.000000000000000000000000000000
0.000000000000000000000000000000
0.000000000000000000000000000000
0.000000000000000000000000000000
0.000000000000000000000000000000
0.0...

result:

ok 

Test #13:

score: 0
Accepted
time: 35ms
memory: 3896kb

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.000000000000000000000000000000
0.000000000000000000000000000000
0.000000000000000000000000000000
0.000000000000000000000000000000
0.000000000000000000000000000000
0.000000000000000000000000000000
0.000000000000000000000000000000
0.000000000000000000000000000000
0.000000000000000000000000000000
0.0...

result:

ok 

Test #14:

score: 0
Accepted
time: 31ms
memory: 3820kb

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.000000000000000000000000000000
0.000000000000000000000000000000
0.000000000000000000000000000000
0.000000000000000000000000000000
0.000000000000000000000000000000
0.000000000000000000000000000000
0.000000000000000000000000000000
0.000000000000000000000000000000
0.000000000000000000000000000000
0.0...

result:

ok 

Test #15:

score: 0
Accepted
time: 31ms
memory: 3900kb

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.000000000000000000000000000000
1.000000000000000000000000000000
1.000000000000000000000000000000
1.000000000000000000000000000000
1.000000000000000000000000000000
1.000000000000000000000000000000
1.000000000000000000000000000000
1.000000000000000000000000000000
1.000000000000000000000000000000
1.0...

result:

ok 

Test #16:

score: 0
Accepted
time: 79ms
memory: 3892kb

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.000000000000000000000000000000
99999999999999999996693535322073426194986990198284960792713915417520186694826443244189778401170554880.000000000000000000000000000000
9999999999999999999669353532207342...

result:

ok 

Test #17:

score: 0
Accepted
time: 238ms
memory: 3820kb

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: 67ms
memory: 3720kb

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.000000000000000000000000000000
887520371224771505660930051115048130581194377754120552263450624.000000000000000000000000000000
887520371224771505660930051115048130581194377754120552263450624.000000000000000000000000000000
887520371224771...

result:

ok 

Test #19:

score: 0
Accepted
time: 233ms
memory: 3900kb

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: 80ms
memory: 3784kb

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.000000000000000000000000000000
99999998990000004703760194837458282425585003360889281090156809791954306223437356096465459080102674432.000000000000000000000000000000
9999999899000000470376019483745828...

result:

ok 

Test #21:

score: 0
Accepted
time: 1ms
memory: 3680kb

input:

1 1
1 a = 0.001 b
0.001 a to b

output:

0.000000999999999999999999932853

result:

ok 

Test #22:

score: 0
Accepted
time: 1ms
memory: 3808kb

input:

1 1
1 a = 1 b
1 a to b

output:

1.000000000000000000000000000000

result:

ok 

Test #23:

score: 0
Accepted
time: 1ms
memory: 3696kb

input:

1 1
1 a = 1 b
1 a to a

output:

1.000000000000000000000000000000

result:

ok 

Test #24:

score: 0
Accepted
time: 0ms
memory: 3684kb

input:

1 1
1 a = 1000 b
1000 a to b

output:

1000000.000000000000000000000000000000

result:

ok 

Test #25:

score: -100
Wrong Answer
time: 1ms
memory: 3868kb

input:

2 1
1 a = 1 b
1 c = 1 d
1 a to d

output:

0.000000000000000000000000000000

result:

wrong answer