QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#817453#4569. Connect the PointsSGColinAC ✓0ms3964kbC++201.4kb2024-12-16 23:20:092024-12-16 23:20:10

Judging History

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

  • [2024-12-16 23:20:10]
  • 评测
  • 测评结果:AC
  • 用时:0ms
  • 内存:3964kb
  • [2024-12-16 23:20:09]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

inline ll rd() {
	ll x = 0;
	bool f = 0;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) f |= (c == '-');
	for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
	return f ? -x : x;
} 

ll x[5], y[5], s[5];

#define abs(x) ((x) > 0 ? (x) : -(x))

#define mp make_pair
#define fr first
#define sc second
#define pb push_back

struct seg {
	ll a, b, c, d;
};

ll ans = 1e18, tmp;

vector<seg> q, tmpq;

void add(ll x1, ll y1, ll x2, ll y2) {
	if (x1 == x2 && y1 == y2) return;
	tmp += abs(x1 - x2) + abs(y1 - y2);
	tmpq.pb((seg){x1, y1, x2, y2});
}

int main() {
	for (int i = 0; i < 3; ++i) {
		x[i] = rd(); y[i] = rd();
	}
	ll mnx = min(min(x[0], x[1]), x[2]);
	ll mxx = max(max(x[0], x[1]), x[2]);
	ll mny = min(min(y[0], y[1]), y[2]);
	ll mxy = max(max(y[0], y[1]), y[2]);
	ll ans = 1e18;
	for (ll i = 0; i < 3; ++i) {
		ll j = (i == 0 ? 1 : 0);
		ll k = 3 - i - j;
		tmp = 0; tmpq.clear();
		add(mnx, y[i], mxx, y[i]);
		add(x[j], y[j], x[j], y[i]);
		add(x[k], y[k], x[k], y[i]);
		if (tmp < ans) {ans = tmp; q = tmpq;}
		tmp = 0; tmpq.clear();
		add(x[i], mny, x[i], mxy);
		add(x[j], y[j], x[i], y[j]);
		add(x[k], y[k], x[i], y[k]);
		if (tmp < ans) {ans = tmp; q = tmpq;}
	}
	printf("%lld\n", q.size());
	for (auto i : q) 
		printf("%lld %lld %lld %lld\n", i.a, i.b, i.c, i.d);
	return 0;
}

詳細信息

Test #1:

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

input:

1 1
3 5
8 6

output:

3
1 5 8 5
1 1 1 5
8 6 8 5

result:

ok Total length is 12

Test #2:

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

input:

1 1
2 2
3 3

output:

3
1 2 3 2
1 1 1 2
3 3 3 2

result:

ok Total length is 4

Test #3:

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

input:

1 1
2 3
3 2

output:

3
2 1 2 3
1 1 2 1
3 2 2 2

result:

ok Total length is 4

Test #4:

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

input:

1 2
2 1
3 3

output:

3
1 2 3 2
2 1 2 2
3 3 3 2

result:

ok Total length is 4

Test #5:

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

input:

1 2
2 3
3 1

output:

3
1 2 3 2
2 3 2 2
3 1 3 2

result:

ok Total length is 4

Test #6:

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

input:

1 3
2 1
3 2

output:

3
2 1 2 3
1 3 2 3
3 2 2 2

result:

ok Total length is 4

Test #7:

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

input:

1 3
2 2
3 1

output:

3
1 2 3 2
1 3 1 2
3 1 3 2

result:

ok Total length is 4

Test #8:

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

input:

-811089219 -147580223
-131318959 -47863115
180743101 601547107

output:

3
-811089219 -47863115 180743101 -47863115
-811089219 -147580223 -811089219 -47863115
180743101 601547107 180743101 -47863115

result:

ok Total length is 1740959650

Test #9:

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

input:

-953648657 -254962225
-198962039 539064186
536177467 -81912224

output:

3
-198962039 -254962225 -198962039 539064186
-953648657 -254962225 -198962039 -254962225
536177467 -81912224 -198962039 -81912224

result:

ok Total length is 2283852535

Test #10:

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

input:

170075350 644693857
-70945648 -531201615
-813420873 75995752

output:

3
-70945648 -531201615 -70945648 644693857
170075350 644693857 -70945648 644693857
-813420873 75995752 -70945648 75995752

result:

ok Total length is 2159391695

Test #11:

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

input:

-598308052 155442794
-752953801 111986435
782202531 -333732768

output:

3
-598308052 -333732768 -598308052 155442794
-752953801 111986435 -598308052 111986435
782202531 -333732768 -598308052 -333732768

result:

ok Total length is 2024331894

Test #12:

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

input:

140537651 392873314
856272625 199854620
284394957 -862945504

output:

3
140537651 199854620 856272625 199854620
140537651 392873314 140537651 199854620
284394957 -862945504 284394957 199854620

result:

ok Total length is 1971553792

Test #13:

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

input:

-531600195 66788696
495972018 -828643104
-537934741 235845303

output:

3
-537934741 66788696 495972018 66788696
495972018 -828643104 495972018 66788696
-537934741 235845303 -537934741 66788696

result:

ok Total length is 2098395166

Test #14:

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

input:

-565864098 -762723255
903590907 -762723255
-486054726 -762723255

output:

1
-565864098 -762723255 903590907 -762723255

result:

ok Total length is 1469455005

Test #15:

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

input:

80565983 -977814210
80565983 384343197
80565983 102575609

output:

1
80565983 -977814210 80565983 384343197

result:

ok Total length is 1362157407

Test #16:

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

input:

435839201 -838682337
435839201 821052661
499609215 273341058

output:

2
435839201 -838682337 435839201 821052661
499609215 273341058 435839201 273341058

result:

ok Total length is 1723505012

Test #17:

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

input:

435839201 273341058
499609215 821052661
435839201 -838682337

output:

3
435839201 273341058 499609215 273341058
499609215 821052661 499609215 273341058
435839201 -838682337 435839201 273341058

result:

ok Total length is 1723505012

Test #18:

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

input:

-550183491 -223052429
756776472 349902936
239047012 -223052429

output:

2
-550183491 -223052429 756776472 -223052429
756776472 349902936 756776472 -223052429

result:

ok Total length is 1879915328

Test #19:

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

input:

1000000000 894586329
-444648850 -239939045
-733796075 -301669878

output:

3
-733796075 -239939045 1000000000 -239939045
1000000000 894586329 1000000000 -239939045
-733796075 -301669878 -733796075 -239939045

result:

ok Total length is 2930052282

Test #20:

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

input:

669699982 91018932
438054159 1000000000
-364758687 -418769264

output:

3
-364758687 91018932 669699982 91018932
438054159 1000000000 438054159 91018932
-364758687 -418769264 -364758687 91018932

result:

ok Total length is 2453227933

Test #21:

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

input:

-1000000000 -167957680
247368494 215997643
-384275539 -796580213

output:

3
-1000000000 -167957680 247368494 -167957680
247368494 215997643 247368494 -167957680
-384275539 -796580213 -384275539 -167957680

result:

ok Total length is 2259946350

Test #22:

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

input:

-619431287 -131966997
616405883 224993162
793394764 -1000000000

output:

3
-619431287 -131966997 793394764 -131966997
616405883 224993162 616405883 -131966997
793394764 -1000000000 793394764 -131966997

result:

ok Total length is 2637819213

Test #23:

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

input:

1000000000 127343545
-28934934 951599244
274060166 -1000000000

output:

3
-28934934 127343545 1000000000 127343545
-28934934 951599244 -28934934 127343545
274060166 -1000000000 274060166 127343545

result:

ok Total length is 2980534178

Test #24:

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

input:

-950000000 950000000
629494532 268139913
853768075 -8108129

output:

3
-950000000 268139913 853768075 268139913
-950000000 950000000 -950000000 268139913
853768075 -8108129 853768075 268139913

result:

ok Total length is 2761876204