QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#71766#3553. Hamburg SteakHe_Ren2 166ms8468kbC++143.5kb2023-01-12 01:01:052023-01-12 01:01:57

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-01-12 01:01:57]
  • 评测
  • 测评结果:2
  • 用时:166ms
  • 内存:8468kb
  • [2023-01-12 01:01:05]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN = 2e5 + 5;
const int MAXD = 4 + 5;
const int C = 1e9;
const ll linf = 0x3f3f3f3f3f3f3f3f;

struct Rec
{
	int xl, xr, yl, yr;
	bool valid(void) const { return xl <= xr && yl <= yr;}
	bool isin(int x,int y) const { return xl <= x && x <= xr && yl <= y && y <= yr;}
	ll area(void) const { return (ll)(xr - xl + 1) * (yr - yl + 1);}
	void read_self(void){ scanf("%d%d%d%d",&xl,&yl,&xr,&yr);}
};

Rec operator + (const Rec &a,const Rec &b)
{
	return Rec{max(a.xl, b.xl), min(a.xr, b.xr), max(a.yl, b.yl), min(a.yr, b.yr)};
}

int n,d;
Rec p[MAXN], dat[MAXD];
bool valid[MAXN];

vector<int> solve1(vector<pii> vec)
{
	sort(vec.begin(), vec.end(), [] (pii x,pii y){
		return x.second < y.second;
	});
	
	vector<int> res;
	int lst = -C;
	for(pii t: vec) if(t.first > lst)
		res.push_back(lst = t.second);
	return res;
}

int dsc[MAXN * 2], dcnt = 0;

void print(int cur)
{
	for(int i=1; i<=cur; ++i)
		printf("%d %d\n",dsc[dat[i].xl],dsc[dat[i].yl]);
	for(int i=cur+1; i<=d; ++i)
		printf("1 1\n");
	exit(0);
}

void dfs(int cur)
{
	if(cur >= d) return;
	
	Rec lim = {-C, C, -C, C};
	for(int i=1; i<=n; ++i) if(!valid[i])
		lim = lim + p[i];
	if(lim.valid())
	{
		dat[++cur] = lim;
		print(cur);
	}
	
	if(lim.xl <= lim.xr)
	{
		vector<pii> vec;
		for(int i=1; i<=n; ++i) if(!valid[i])
			vec.emplace_back(p[i].yl, p[i].yr);
		vector<int> res = solve1(vec);
		if(cur + (int)res.size() > d) return;
		for(int y: res) dat[++cur] = {lim.xl, lim.xr, y, y};
		print(cur);
	}
	if(lim.yl <= lim.yr)
	{
		vector<pii> vec;
		for(int i=1; i<=n; ++i) if(!valid[i])
			vec.emplace_back(p[i].xl, p[i].xr);
		vector<int> res = solve1(vec);
		if(cur + (int)res.size() > d) return;
		for(int x: res) dat[++cur] = {x, x, lim.yl, lim.yr};
		print(cur);
	}
	
	auto chs = [&] (int x,int y)
	{
		vector<int> use;
		for(int i=1; i<=n; ++i)
			if(!valid[i] && p[i].isin(x,y))
				valid[i] = 1, use.push_back(i);
		if(!use.size()) return;
		dat[cur+1] = {x,x,y,y};
		dfs(cur+1);
		for(int i: use) valid[i] = 0;
	};
	
	chs(lim.xl, lim.yl);
	chs(lim.xr, lim.yl);
	chs(lim.xl, lim.yr);
	chs(lim.xr, lim.yr);
	
	assert(d == 4);
	while(1)
	{
		random_shuffle(p+1,p+n+1);
		dat[1] = {lim.xr, lim.xl, lim.yl, lim.yl};
		dat[2] = {lim.xr, lim.xl, lim.yr, lim.yr};
		dat[3] = {lim.xl, lim.xl, lim.yr, lim.yl};
		dat[4] = {lim.xr, lim.xr, lim.yr, lim.yl};
		
		bool ok = 1;
		for(int i=1; i<=n && ok; ++i)
		{
			int pos = -1;
			ll mndec = linf;
			for(int j=1; j<=d; ++j)
			{
				Rec nxt = dat[j] + p[i];
				if(!nxt.valid()) continue;
				ll dec = dat[j].area() - nxt.area();
				if(dec < mndec) pos = j, mndec = dec;
			}
			if(pos == -1)
			{
				ok = 0;
				break;
			}
			dat[pos] = dat[pos] + p[i];
		}
		
		if(ok) print(d);
	}
}

int main(void)
{
	srand((unsigned long long)new char ^ time(0));
	
	scanf("%d%d",&n,&d);
	for(int i=1; i<=n; ++i) p[i].read_self();
	
	for(int i=1; i<=n; ++i)
		dsc[++dcnt] = p[i].xl,
		dsc[++dcnt] = p[i].yl;
	sort(dsc+1,dsc+dcnt+1);
	dcnt = unique(dsc+1,dsc+dcnt+1) - dsc - 1;
	for(int i=1; i<=n; ++i)
	{
		p[i].xl = lower_bound(dsc+1,dsc+dcnt+1, p[i].xl) - dsc;
		p[i].yl = lower_bound(dsc+1,dsc+dcnt+1, p[i].yl) - dsc;
		p[i].xr = upper_bound(dsc+1,dsc+dcnt+1, p[i].xr) - dsc - 1;
		p[i].yr = upper_bound(dsc+1,dsc+dcnt+1, p[i].yr) - dsc - 1;
	}
	
	dfs(0);
	return 0;
}

详细

Subtask #1:

score: 1
Accepted

Test #1:

score: 1
Accepted
time: 1ms
memory: 3788kb

input:

1936 1
275634612 269663887 525116613 936487725
97408668 7442476 814869170 687312206
436819238 107950642 958111100 591552952
7518596 205530980 782566587 854412425
496572510 309198877 998274921 764947740
205948014 311140816 696959672 600779117
332275583 5172242 984611829 780400859
404519140 226954535 ...

output:

500095467 495713566

result:

ok good solution

Test #2:

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

input:

1918 1
101495422 186906933 732615030 881441564
458968315 389772762 517376914 972253676
310129691 156509236 593443672 871966220
91341901 261855863 618682147 864249047
98953032 286357489 522693657 556560771
364790412 127843696 903079225 858654564
329423949 270896020 835948130 589093351
409677593 11179...

output:

508672104 489724537

result:

ok good solution

Test #3:

score: 0
Accepted
time: 3ms
memory: 3740kb

input:

1934 1
149390016 218273120 829091825 943957108
465523240 256616763 562611479 561076814
346779336 19349510 498782244 682919444
355187765 473117629 640518942 857154270
428523527 118919644 980443851 505620423
466172753 4854201 565577102 807575992
63057309 306335591 995966133 973208230
277575294 4065971...

output:

484482652 483569842

result:

ok good solution

Test #4:

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

input:

1943 1
447209427 299197697 579958454 975073773
487022253 6405471 553460639 504906460
483616875 87124408 626036564 533315255
33872888 223251549 940210689 985284538
357235178 224597124 537290418 632810537
45568075 166890122 737266711 881843529
465884824 148626173 976612493 608624682
90616486 330697147...

output:

499714107 499094214

result:

ok good solution

Subtask #2:

score: 0
Dangerous Syscalls

Test #5:

score: 1
Accepted
time: 3ms
memory: 3852kb

input:

1928 2
257715250 61165602 852430884 888048968
291121137 322570367 570606015 908598504
418176729 319924920 611676731 632485660
33180758 215166338 468783003 795212414
441068331 188624227 750676748 613482091
344172819 322492096 940801573 568738370
246507550 338324125 785514636 678843646
100885653 12352...

output:

553348827 550579979
376616176 496147660

result:

ok good solution

Test #6:

score: -1
Dangerous Syscalls

input:

1997 2
56211994 316470697 834713588 994523430
210478797 475173819 947781150 830967427
165103446 297758631 889994221 924850963
249357370 47257846 820487698 384771182
162610336 510100040 380663547 767626913
508466455 49691754 723323852 412277960
131060304 545781419 581816995 764877614
379085656 131818...

output:


result:


Subtask #3:

score: 0
Dangerous Syscalls

Test #9:

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

input:

1980 3
580358104 434053443 986861108 684634218
125969708 5379869 593299091 644204766
366688051 54873592 662708561 602035535
211630750 166795940 981075947 676159693
524950613 414516203 951984898 573261034
10925143 210994662 543601795 609644115
82102881 63393894 401995062 922075556
245641393 276511435...

output:

275355682 497455773
437786479 497455773
816253792 497455773

result:

ok good solution

Test #10:

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

input:

1979 3
166188766 501732855 696148516 858594442
448642394 649848030 826585058 892841834
227996253 41181673 597994927 735947663
496120536 146174371 797127295 937876819
142223416 54620669 692019448 761376043
155423015 310182182 964649015 766725969
149600215 175625826 795416544 456728413
409645085 19620...

output:

502336852 173446283
502336852 417006429
502336852 779897623

result:

ok good solution

Test #11:

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

input:

1970 3
6326130 464942284 388518354 882271741
66547837 401410194 771818574 964118705
431296737 152301456 768358217 594183143
100119464 369214977 761673174 593619290
554322598 400289117 890806483 611831145
468030782 120235085 570300617 574227571
536074322 234244025 972122902 923424073
23842325 1375292...

output:

183975187 505601682
503115886 505601682
840903510 505601682

result:

ok good solution

Test #12:

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

input:

1902 3
46256098 223546319 976063314 679892427
208941639 360798602 514564801 525784990
495657906 481262200 583411507 834786567
114474902 217453369 507936464 977145349
438812862 137761110 659874190 748450508
150051630 320174167 709890617 749271580
461931817 349133710 721176664 894961254
191481592 2311...

output:

505976751 463511684
505976751 494442549
505976751 702759714

result:

ok good solution

Test #13:

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

input:

1907 3
529222873 269079360 606281098 544233180
314098028 205582496 956371826 693781800
597306909 130431170 803836008 957760548
408036487 187293717 724824626 505243368
350711336 299117505 435879209 571407168
174973325 274977214 964591728 872823303
510414120 308728615 922852742 648065611
189182981 254...

output:

425510600 493167932
553268752 493167932
756539307 493167932

result:

ok good solution

Test #14:

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

input:

1970 3
247787183 554327787 833105239 866790305
120159458 77503852 873229562 905079773
185669053 286943969 889204476 523300675
380807551 291006183 835038004 557132574
75131701 112833287 948346627 443744421
354678253 96682911 955772616 484278967
433630055 398080908 741228310 947667112
3270468 34884373...

output:

504095743 385721557
504095743 455015020
504095743 816980623

result:

ok good solution

Test #15:

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

input:

1932 3
63246664 100992328 708815832 279735345
587087611 695076361 990493105 950911045
51692549 99485997 687018700 357429553
152292750 738983462 949997376 855566683
342538620 308426803 888779255 910042046
240526865 363218287 878993972 988330889
270212614 40812223 790412608 864162583
25359443 83389322...

output:

736731527 771629864
640705316 606145173
176213793 189284457

result:

ok good solution

Test #16:

score: -3
Dangerous Syscalls

input:

1916 3
177572158 724583533 540234450 904554416
267369796 380070616 780117040 973060129
271971234 17096943 908591131 436843715
343216202 326902387 763886033 489700904
77694275 111501224 554830396 834241644
305611167 222890871 895960336 810316211
274217306 278623998 739543117 517845242
98047272 523947...

output:


result:


Subtask #4:

score: 0
Time Limit Exceeded

Test #21:

score: 6
Accepted
time: 3ms
memory: 3880kb

input:

1989 4
20688201 462820019 870557654 779905491
299122723 258293216 630017062 521792413
430322558 33567880 691187720 757852374
104994597 262388698 979697437 904439328
237383344 375297588 673858769 638443621
715773360 364818076 896724313 888051478
235043050 422124296 833892854 936850257
434942952 25412...

output:

302871638 495357540
433193317 495357540
489301131 495357540
740481982 495357540

result:

ok good solution

Test #22:

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

input:

1913 4
447764235 131766500 662143128 594925961
175752030 143370745 850970381 604940594
315760617 440375785 908808188 914216196
111980814 70287311 781633529 646769135
18056623 198611867 512791707 850722100
131263504 97431361 865097956 701669444
262211923 224930035 533039033 706346045
107163409 354652...

output:

507482141 232977509
507482141 464549938
507482141 596063455
507482141 600026992

result:

ok good solution

Test #23:

score: 0
Accepted
time: 3ms
memory: 3908kb

input:

1920 4
403612171 130212084 610839654 977155495
174635909 382477705 375033887 769530611
340136940 313829516 474317741 726135356
143616239 178727187 803624314 507947866
577185790 343964260 782890837 795447335
110525706 212833414 627795187 902056221
422130567 424467473 774573585 903486772
3517217 11536...

output:

239694881 493355384
430918444 493355384
701564602 493355384
753054834 493355384

result:

ok good solution

Test #24:

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

input:

1976 4
7843810 299539661 895205452 838927376
179469298 530734693 839498393 906942557
425264917 463297089 997915975 587521801
215733519 172023687 820614514 421745698
382289292 316607805 946907834 645956684
102596607 119790611 920274659 594156596
145606189 94403987 789918902 982580694
85701841 3496293...

output:

516004179 230445290
516004179 306641042
516004179 520737534
516004179 620914908

result:

ok good solution

Test #25:

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

input:

1968 4
569762634 413660945 933413828 907592006
553091331 263501907 981114109 510693822
407556498 479794645 954385716 677978739
77839764 401024402 183593148 732012557
616679205 368473631 728570013 616691885
452758528 188719816 688654834 653247648
319982735 473076444 920731787 879714237
362388115 4204...

output:

129392334 493681669
467581076 493681669
676207502 493681669
784152404 493681669

result:

ok good solution

Test #26:

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

input:

1970 4
308538176 235176379 968596168 680491401
241796248 642213758 896200579 966943854
34154047 430842591 988563099 762275468
127220131 391604701 725954185 805334309
406770564 392602905 660975191 797637410
405127709 114423654 637785229 245574946
249335622 304910296 692529558 647952360
279608285 3767...

output:

499057790 232638246
499057790 476392522
499057790 505431008
499057790 717993694

result:

ok good solution

Test #27:

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

input:

1995 4
218769975 589730993 868473449 983195504
99642551 105395469 263017574 322188569
10919242 366513432 998689738 441858800
242833555 350501403 626327785 862719993
98060564 109694549 535508020 957577096
282072403 179186084 803555658 952336184
272714476 245127036 731196128 684098817
551460894 513882...

output:

695139406 751282560
491696792 546211507
467269428 387429400
155513147 211870480

result:

ok good solution

Test #28:

score: -6
Time Limit Exceeded

input:

1982 4
426949385 131714564 807283432 920017811
681701387 341683408 962502629 853492031
150366255 58801937 994183172 506912367
170582291 304917278 573455982 749277224
258634785 197971430 663392013 592199945
61772927 246608932 801989071 909214540
108026935 615182713 831539950 841653460
293024629 23604...

output:


result:


Subtask #5:

score: 1
Accepted

Dependency #1:

100%
Accepted

Test #79:

score: 1
Accepted
time: 145ms
memory: 8468kb

input:

199927 1
438629555 351412894 521316748 962909150
4328400 108580550 683171263 836435313
256786425 198212822 578214653 567880535
256673124 384187605 616347107 546662355
17067286 405399036 782995564 759479522
41592585 336223869 779372332 767950897
144763906 27980775 808755799 769950439
190038989 499607...

output:

501216738 500047594

result:

ok good solution

Test #80:

score: 0
Accepted
time: 136ms
memory: 8380kb

input:

199992 1
468369692 51432142 943101549 608968278
127680231 369941094 634667730 516371960
1427728 371977761 569293553 552853223
257885457 347434207 972596280 837837513
12529484 152139714 579576459 897919247
336613920 369023033 998436991 994236118
199517636 485859301 866178585 867603970
240114269 23997...

output:

498944351 501259180

result:

ok good solution

Test #81:

score: 0
Accepted
time: 157ms
memory: 8432kb

input:

199959 1
238817589 70537254 695436468 882043893
416319574 329705088 750294846 997603367
122039910 48189248 775821782 942409460
123142019 92806058 723431298 750522560
4786698 304382499 682308754 815818931
464345660 36298510 907436621 659933836
147740222 250356542 768868832 810218769
141166042 2446879...

output:

497944813 499769052

result:

ok good solution

Test #82:

score: 0
Accepted
time: 166ms
memory: 8436kb

input:

199975 1
140647043 401141353 909868027 932502018
352011992 220163287 771463853 980296352
361128104 404877280 696161321 507368200
4311205 146503975 844576299 861932439
400068006 401139622 794199519 902157094
159967166 324845985 527699521 828787788
305950684 85836346 695843414 724376480
348091458 4722...

output:

500059611 498126287

result:

ok good solution

Subtask #6:

score: 0
Skipped

Dependency #2:

0%

Subtask #7:

score: 0
Skipped

Dependency #3:

0%

Subtask #8:

score: 0
Skipped

Dependency #4:

0%