QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#566010#7727. Linear GradientCrysflyAC ✓1ms4056kbC++142.6kb2024-09-15 22:53:032024-09-15 22:53:06

Judging History

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

  • [2024-09-15 22:53:06]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:4056kb
  • [2024-09-15 22:53:03]
  • 提交

answer

/////////////////////////////////
#include <bits/stdc++.h>
using db = long double;
int main() {
	// freopen("in.txt", "r", stdin);
	std::ios::sync_with_stdio(false), std::cin.tie(0);
	int x1, y1, y2;
	int rl, gl, bl;
	std::cin >> x1 >> y1 >> y2;
	std::cin >> rl >> gl >> bl;
	int x2, y3, y4;
	int rr, gr, br;
	std::cin >> x2 >> y3 >> y4;
	std::cin >> rr >> gr >> br;
	std::array<db, 3> ans{};
	auto check = [&] (db x) {
		db t = (x - x1) / (x2 - x1);
		db r = rl * (1 - t) + rr * t;
		db g = gl * (1 - t) + gr * t;
		db b = bl * (1 - t) + br * t;
		if(r >= 150 && g <= 75 && b <= 75) return 0;
		if(g >= 150 && r <= 75 && b <= 75) return 1;
		if(b >= 150 && r <= 75 && g <= 75) return 2;
		return -1;		
	};
	auto len = [&] (db x) {
		db t = (x - x1) / (x2 - x1);
		return y2 * (1 - t) + y4 * t - y1 * (1 - t) - y3 * t;
	};
	auto calc = [&] (db l, db r) {
		db a = len(l), b = len(r);
		return (a + b) * (r - l) / 2;
	};
	std::vector<db> v;
	auto solve = [&] (db l, db r) {
		std::vector<std::tuple<db, db, int>> range;
		if(l >= 150 && r >= 150) {
			range.emplace_back(x1, x2, 1);
		} else if(l >= 150) {
			range.emplace_back(x1, x1 + (x2 - x1) * (l - 150) / (l - r), 1);
		} else if(r >= 150) {
			range.emplace_back(x2 - (x2 - x1) * (r - 150) / (r - l), x2, 1);
		}
		
		if(l <= 75 && r <= 75) {
			range.emplace_back(x1, x2, -1);
		} else if(l <= 75) {
			range.emplace_back(x1, x1 + (x2 - x1) * (75 - l) / (r - l), -1);
		} else if(r <= 75) {
			range.emplace_back(x2 - (x2 - x1) * (75 - r) / (l - r), x2, -1);
		}
		for(auto [l, r, o] : range) {
			v.emplace_back(l);
			v.emplace_back(r);
		}
		return range;
	};
	auto r = solve(rl, rr);
	auto g = solve(gl, gr);
	auto b = solve(bl, br);
	std::sort(v.begin(), v.end());
	v.erase(std::unique(v.begin(), v.end()), v.end());
	std::vector<std::vector<int>> c(3, std::vector<int> (v.size()));
	int id = 0;
	for(auto vec : {r, g, b}) {
		for(auto [l, r, o] : vec) {
			l = std::lower_bound(v.begin(), v.end(), l) - v.begin();
			r = std::lower_bound(v.begin(), v.end(), r) - v.begin();
			for(int i = l; i < r; i ++) {
				c[id][i] = o;
			}
		}
		id ++;
	}
	for(int i = 0; i < v.size(); i ++) {
		if(c[0][i] == 1 && c[1][i] == -1 && c[2][i] == -1) ans[0] += calc(v[i], v[i + 1]);
		if(c[0][i] == -1 && c[1][i] == 1 && c[2][i] == -1) ans[1] += calc(v[i], v[i + 1]);
		if(c[0][i] == -1 && c[1][i] == -1 && c[2][i] == 1) ans[2] += calc(v[i], v[i + 1]);
	}
	std::cout << std::fixed << std::setprecision(10);
	for(int i = 0; i < 3; i ++) {
		std::cout << ans[i] << '\n';
	}	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

0 0 50 255 0 0
100 0 100 0 255 0

output:

1686.8512110727
2724.9134948097
0.0000000000

result:

ok 3 numbers

Test #2:

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

input:

2060 62118 92121 239 136 80
61328 12685 18891 50 69 122

output:

0.0000000000
0.0000000000
0.0000000000

result:

ok 3 numbers

Test #3:

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

input:

85238 49611 95092 67 6 208
85360 45143 87657 104 126 133

output:

0.0000000000
0.0000000000
1191253.9839298758

result:

ok 3 numbers

Test #4:

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

input:

57680 36610 53516 78 65 31
81738 82352 90031 77 79 44

output:

0.0000000000
0.0000000000
0.0000000000

result:

ok 3 numbers

Test #5:

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

input:

91940 22309 99142 30 143 62
95387 37573 91801 180 71 34

output:

10504908.0416666667
0.0000000000
0.0000000000

result:

ok 3 numbers

Test #6:

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

input:

68239 45093 91137 51 183 30
86340 11944 39045 0 208 122

output:

0.0000000000
366644421.6236413044
0.0000000000

result:

ok 3 numbers

Test #7:

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

input:

5408 36608 48052 206 29 193
65865 29822 78504 214 12 2

output:

960445272.3630108823
0.0000000000
0.0000000000

result:

ok 3 numbers

Test #8:

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

input:

16857 976 61590 203 5 58
59842 72203 74899 167 139 204

output:

286502399.5611277914
0.0000000000
0.0000000000

result:

ok 3 numbers

Test #9:

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

input:

65363 17442 63076 12 67 206
83708 28211 29809 182 150 123

output:

0.0000000000
0.0000000000
76937220.3919291625

result:

ok 3 numbers

Test #10:

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

input:

73730 85011 89704 19 244 78
84775 10494 71515 178 172 90

output:

0.0000000000
0.0000000000
0.0000000000

result:

ok 3 numbers

Test #11:

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

input:

15380 43193 80471 79 12 138
34588 55347 86722 56 24 213

output:

0.0000000000
0.0000000000
536530146.9413988659

result:

ok 3 numbers

Test #12:

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

input:

50 100 300 75 75 150
1000 0 10 75 75 150

output:

0.0000000000
0.0000000000
99750.0000000000

result:

ok 3 numbers

Test #13:

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

input:

0 1000 2000 255 80 70
1000 0 5000 255 70 80

output:

0.0000000000
0.0000000000
0.0000000000

result:

ok 3 numbers

Test #14:

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

input:

2088 11589 49794 50 74 197
39482 34249 94468 160 37 6

output:

201310135.4380165288
0.0000000000
345950513.7396694215

result:

ok 3 numbers

Test #15:

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

input:

51902 63928 83921 242 44 37
68920 49265 66486 37 242 4

output:

52691853.5757575757
55135069.8758358120
0.0000000000

result:

ok 3 numbers

Test #16:

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

input:

12086 45400 84815 34 177 73
13903 1944 25669 245 36 71

output:

13014112.3856948846
13191222.5894069715
0.0000000000

result:

ok 3 numbers

Test #17:

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

input:

6872 17701 20950 247 6 1
21542 48952 90939 7 169 20

output:

65678721.0671875000
67937041.1042944785
0.0000000000

result:

ok 3 numbers

Test #18:

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

input:

23054 31939 71419 39 43 178
79732 25616 77333 205 55 41

output:

706096329.8204486120
0.0000000000
471814934.4531940966

result:

ok 3 numbers

Test #19:

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

input:

72463 11051 89269 58 182 50
77950 55529 86785 46 9 204

output:

0.0000000000
66277035.9556839262
75978498.2545117220

result:

ok 3 numbers

Test #20:

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

input:

43212 19326 62326 44 27 228
75450 58082 85211 44 180 47

output:

0.0000000000
141416983.4422636672
409717736.9688581315

result:

ok 3 numbers

Test #21:

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

input:

36950 6955 51410 168 1 28
91461 18712 93316 34 34 237

output:

340343411.4824014257
0.0000000000
1167372498.7361606152

result:

ok 3 numbers

Test #22:

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

input:

60250 20949 98693 46 249 30
87595 20162 70798 196 8 44

output:

413587603.8344725471
397155724.6520000002
0.0000000000

result:

ok 3 numbers

Test #23:

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

input:

39757 85711 91706 55 181 47
76150 63728 89807 60 75 197

output:

0.0000000000
53460391.8090666667
0.0000000000

result:

ok 3 numbers

Test #24:

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

input:

14989 24328 84695 0 0 0
82788 95102 98565 255 255 255

output:

0.0000000000
0.0000000000
0.0000000000

result:

ok 3 numbers

Test #25:

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

input:

65115 26976 85220 255 0 0
80275 70453 96243 255 0 0

output:

636977720.0000000000
0.0000000000
0.0000000000

result:

ok 3 numbers

Test #26:

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

input:

24932 14186 46205 0 255 0
72534 47190 51666 0 255 0

output:

0.0000000000
868617495.0000000000
0.0000000000

result:

ok 3 numbers

Test #27:

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

input:

15628 12010 95180 0 0 255
86243 9027 75885 0 0 255

output:

0.0000000000
0.0000000000
5297113610.0000000000

result:

ok 3 numbers

Test #28:

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

input:

53808 24611 48271 0 255 255
78724 42729 63863 0 255 255

output:

0.0000000000
0.0000000000
0.0000000000

result:

ok 3 numbers

Test #29:

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

input:

47151 6823 18005 255 0 255
60107 48980 85238 255 0 255

output:

0.0000000000
0.0000000000
0.0000000000

result:

ok 3 numbers

Test #30:

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

input:

25961 18270 37223 255 255 0
34488 32109 35238 255 255 0

output:

0.0000000000
0.0000000000
0.0000000000

result:

ok 3 numbers

Test #31:

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

input:

27019 37875 50350 150 0 0
80548 35967 45816 150 0 0

output:

597490698.0000000000
0.0000000000
0.0000000000

result:

ok 3 numbers

Test #32:

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

input:

43817 58155 63638 0 150 0
67353 40148 94799 0 150 0

output:

0.0000000000
707656912.0000000000
0.0000000000

result:

ok 3 numbers

Test #33:

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

input:

17883 12199 12579 0 0 150
43763 57151 92475 0 0 150

output:

0.0000000000
0.0000000000
462009760.0000000000

result:

ok 3 numbers

Test #34:

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

input:

3760 81717 92839 150 75 75
22420 47952 66144 150 75 75

output:

273499620.0000000000
0.0000000000
0.0000000000

result:

ok 3 numbers

Test #35:

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

input:

24120 43360 60521 75 150 75
76486 5773 47129 75 150 75

output:

0.0000000000
1532150611.0000000000
0.0000000000

result:

ok 3 numbers

Test #36:

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

input:

31278 31002 77751 75 75 150
63805 1954 36070 75 75 150

output:

0.0000000000
0.0000000000
1315147927.5000000000

result:

ok 3 numbers

Test #37:

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

input:

55896 42144 62511 140 40 90
81612 33284 77007 160 80 20

output:

351257254.8750000000
0.0000000000
0.0000000000

result:

ok 3 numbers

Test #38:

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

input:

54346 17898 29934 90 140 40
68366 19482 31641 20 160 80

output:

0.0000000000
63723857.3437500000
0.0000000000

result:

ok 3 numbers

Test #39:

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

input:

68298 38275 89969 40 90 140
82546 31143 55084 80 20 160

output:

0.0000000000
0.0000000000
174255600.1875000000

result:

ok 3 numbers

Test #40:

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

input:

51955 16926 19423 255 0 0
65803 24209 35160 0 0 0

output:

24162891.2387543253
0.0000000000
0.0000000000

result:

ok 3 numbers

Test #41:

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

input:

38117 35974 61581 0 255 0
58199 51083 90020 0 0 0

output:

0.0000000000
234439491.6124567474
0.0000000000

result:

ok 3 numbers

Test #42:

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

input:

71296 50305 89064 0 0 255
98723 31860 50378 0 0 0

output:

0.0000000000
0.0000000000
390660745.1401384083

result:

ok 3 numbers

Test #43:

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

input:

24504 7347 80033 150 75 0
46739 30661 95335 0 75 150

output:

0.0000000000
0.0000000000
0.0000000000

result:

ok 3 numbers

Test #44:

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

input:

62039 66239 66588 0 150 75
86256 24430 70272 150 0 75

output:

0.0000000000
0.0000000000
0.0000000000

result:

ok 3 numbers

Test #45:

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

input:

21864 17754 21162 75 0 150
62631 40978 48396 75 150 0

output:

0.0000000000
0.0000000000
0.0000000000

result:

ok 3 numbers

Test #46:

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

input:

23951 45985 96456 150 255 255
59171 7078 15703 150 75 75

output:

0.0000000000
0.0000000000
0.0000000000

result:

ok 3 numbers

Test #47:

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

input:

37880 15384 72825 255 150 255
44265 59408 65002 75 150 75

output:

0.0000000000
0.0000000000
0.0000000000

result:

ok 3 numbers

Test #48:

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

input:

21067 1757 75375 255 255 150
63222 4976 21516 75 75 150

output:

0.0000000000
0.0000000000
0.0000000000

result:

ok 3 numbers

Test #49:

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

input:

23659 21454 36284 150 255 255
38361 56012 97445 150 74 74

output:

3359489.1240499375
0.0000000000
0.0000000000

result:

ok 3 numbers

Test #50:

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

input:

5003 4873 87896 255 150 255
21506 55277 90792 74 150 74

output:

0.0000000000
3250109.7160343091
0.0000000000

result:

ok 3 numbers

Test #51:

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

input:

10158 17739 94440 255 255 150
70980 78115 79049 74 74 150

output:

0.0000000000
0.0000000000
384187.0707548610

result:

ok 3 numbers

Test #52:

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

input:

7325 22346 91217 200 0 0
96348 47582 54639 0 0 200

output:

1360811141.9375000000
0.0000000000
329023444.0625000000

result:

ok 3 numbers

Test #53:

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

input:

2266 6600 77536 0 200 0
30793 25851 88669 200 0 0

output:

455239214.8125000000
498660874.6875000000
0.0000000000

result:

ok 3 numbers

Test #54:

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

input:

84306 63330 73678 0 0 200
95136 34678 92792 0 200 0

output:

0.0000000000
141177849.3750000000
44183015.6250000000

result:

ok 3 numbers

Test #55:

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

input:

97528 12352 78709 200 100 100
97929 791 64920 0 0 200

output:

0.0000000000
0.0000000000
9706217.5312500000

result:

ok 3 numbers

Test #56:

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

input:

5260 4966 16978 100 200 100
55192 9215 80160 200 0 0

output:

1121505097.7812500000
0.0000000000
0.0000000000

result:

ok 3 numbers

Test #57:

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

input:

76254 60754 72798 100 100 200
87060 42977 79719 0 200 0

output:

0.0000000000
130122306.2812500000
0.0000000000

result:

ok 3 numbers

Test #58:

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

input:

0 0 100000 0 0 255
100000 0 100000 0 0 255

output:

0.0000000000
0.0000000000
10000000000.0000000000

result:

ok 3 numbers

Test #59:

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

input:

0 0 100000 242 132 79
100000 0 100000 173 6 32

output:

5476190476.1904761903
0.0000000000
0.0000000000

result:

ok 3 numbers

Test #60:

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

input:

0 0 100000 255 0 0
100000 0 100000 0 0 255

output:

2941176470.5882352942
0.0000000000
2941176470.5882352942

result:

ok 3 numbers