QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#95429#5133. Imperfect Imperial Units_b_WA 66ms6680kbC++141.3kb2023-04-09 17:26:262023-04-09 17:26:31

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-09 17:26:31]
  • 评测
  • 测评结果:WA
  • 用时:66ms
  • 内存:6680kb
  • [2023-04-09 17:26:26]
  • 提交

answer

#include<iostream>
#include<map>
#include<utility>
#include<vector>
#include<iomanip>
using namespace std;
#define ld long double
map<pair<string,string>, ld>convert;
map<pair<string, string>, int>book;
vector<string>tol;

int n, q;

int main() {
	cin >> n >> q;
	ld tmp1, tmp2; string s1, s2; string trash;
	for (int i = 0; i < n; i++) {
		cin >> tmp1 >> s1 >> trash >> tmp2 >> s2;
		convert[{s1, s2}] = tmp2 / tmp1; convert[{s2, s1}] = tmp1 / tmp2;
		book[{s1, s2}] = 1; book[{s2, s1}] = 1;
		for (auto& s : tol) {
			if (s != s1 && s != s2) {
				if (book[{s, s1}]) {
					book[{s, s2}] = 1; book[{s2, s}] = 1;
					convert[{s, s2}] = convert[{s, s1}] * convert[{s1, s2}];
					convert[{s2, s}] = convert[{s2, s1}] * convert[{s1, s}];
				}
				else if (book[{s, s2}]) {
					book[{s, s1}] = 1; book[{s1, s}] = 1;
					convert[{s, s1}] = convert[{s, s2}] * convert[{s2, s1}];
					convert[{s1, s}] = convert[{s1, s2}] * convert[{s2, s}];
				}
			}
		}
		tol.push_back(s1); tol.push_back(s2);
	}
	ld target;
	for (int i = 0; i < q; i++) {
		cin >> target >> s1 >> trash >> s2;
		ld ans = target * convert[{s1, s2}];
		if (book[{s1,s2}]==0) {
			cout << "impossible" << endl;
		}
		else {
			cout << setprecision(18) << ans << endl;
		}
	}
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
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.75
1512
impossible

result:

ok 

Test #2:

score: 0
Accepted
time: 2ms
memory: 3512kb

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.24640657084
1.30446428571428571e-05
0.224285714285714286

result:

ok 

Test #3:

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

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:

4.43940350290338495e-18
3.973506798483936e+20

result:

ok 

Test #4:

score: -100
Wrong Answer
time: 66ms
memory: 6680kb

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:

impossible
impossible
impossible
107.44657978777486
impossible
impossible
impossible
43554794.1014903846
impossible
impossible
impossible
impossible
impossible
impossible
impossible
5203224.41028569394
15634.4808961360016
55.3631227366969414
impossible
impossible
impossible
110053.792579874865
impos...

result:

wrong answer