QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#116878#6667. ProsjekKevin5307#16 620ms28892kbC++142.2kb2023-06-30 09:43:192024-05-31 18:33:26

Judging History

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

  • [2024-05-31 18:33:26]
  • 评测
  • 测评结果:16
  • 用时:620ms
  • 内存:28892kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-30 09:43:19]
  • 提交

answer

//Author: Kevin5307
#include<bits/stdc++.h>
//#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define int ll
#define ull unsigned ll
#define pb push_back
#define mp make_pair
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
#define srt(x) sort(ALL(x))
#define rev(x) reverse(ALL(x))
#define rsrt(x) sort(rALL(x))
#define sz(x) (int)(x.size())
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define lb(v,x) (int)(lower_bound(ALL(v),x)-v.begin())
#define ub(v,x) (int)(upper_bound(ALL(v),x)-v.begin())
#define uni(v) v.resize(unique(ALL(v))-v.begin())
#define longer __int128_t
void die(string S){puts(S.c_str());exit(0);}
vector<pii> cur;
bool dfs(vector<int> vec)
{
	if(sz(vec)==1)
	{
		for(auto pr:cur)
			printf("%lld %lld\n",pr.first,pr.second);
		return true;
	}
	for(int i=0;i<sz(vec);i++)
		for(int j=i+1;j<sz(vec);j++)
			if((vec[i]+vec[j])%2==0)
			{
				vector<int> nvec;
				for(int k=0;k<sz(vec);k++)
					if(k!=i&&k!=j)
						nvec.pb(vec[k]);
				nvec.pb((vec[i]+vec[j])/2);
				cur.pb(mp(vec[i],vec[j]));
				if(dfs(nvec))
					return true;
				cur.pop_back();
			}
	return false;
}
signed main()
{
	int t;
	scanf("%lld",&t);
	while(t--)
	{
		int n;
		scanf("%lld",&n);
		vector<int> vec;
		bool flag=1;
		for(int i=1;i<=n;i++)
		{
			int x;
			scanf("%lld",&x);
			vec.pb(x);
			if(x%2)
				flag=0;
		}
		if(flag)
		{
			set<int> st[2];
			for(auto x:vec)
				st[x/2%2].insert(x);
			for(int i=2;i<n;i++)
			{
				if(sz(st[0])>1)
				{
					int x=*st[0].begin();
					st[0].erase(st[0].begin());
					int y=*st[0].begin();
					st[0].erase(st[0].begin());
					int z=(x+y)/2;
					printf("%lld %lld\n",x,y);
					st[z/2%2].insert(z);
				}
				else
				{
					int x=*st[1].begin();
					st[1].erase(st[1].begin());
					int y=*st[1].begin();
					st[1].erase(st[1].begin());
					int z=(x+y)/2;
					printf("%lld %lld\n",x,y);
					st[z/2%2].insert(z);
				}
			}
			vector<int> vec;
			for(auto x:st[0])
				vec.pb(x);
			for(auto y:st[1])
				vec.pb(y);
			printf("%lld %lld\n",vec[0],vec[1]);
		}
		else if(n<=7)
		{
			cur.clear();
			if(!dfs(vec))
				puts("-1");
		}
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Time Limit Exceeded

Test #1:

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

input:

99
4
739880851158065302 19206582949872932 883064254701115295 222072661880779376
7
148399819461615003 209088712310207988 53191076581680214 445068618251612752 230505279594622109 115754892157516718 804173775829453588
2
77979357045500669 41693388829622019
3
341612949433488278 609808714829036935 19994167...

output:

739880851158065302 19206582949872932
883064254701115295 379543717053969117
222072661880779376 631303985877542206
148399819461615003 230505279594622109
209088712310207988 53191076581680214
445068618251612752 115754892157516718
804173775829453588 189452549528118556
131139894445944101 28041175520456473...

result:

ok correct (99 test cases)

Test #2:

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

input:

94
4
522567009208273608 11643656493074325 186427311250002481 123849906165842189
5
106161059262489233 415343718607892434 327977047389442178 962072443749424073 442437950417792236
2
183203550209212188 845051373320458660
4
438596026703410712 750951289026921248 112070483603621346 883810241305765624
4
145...

output:

11643656493074325 186427311250002481
123849906165842189 99035483871538403
522567009208273608 111442695018690296
106161059262489233 962072443749424073
415343718607892434 327977047389442178
442437950417792236 371660382998667306
534116751505956653 407049166708229771
183203550209212188 84505137332045866...

result:

ok correct (94 test cases)

Test #3:

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

input:

100
6
992926089095812859 592566222682195905 851047547791588090 117812034990980493 287668656568989067 500497313856354147
5
422579495815431679 738445394838743009 952584027249447301 804094328392164866 131591678779711861
6
671044256239146581 730689616081395646 623998023808544596 817401707748253055 55805...

output:

992926089095812859 592566222682195905
851047547791588090 792746155889004382
287668656568989067 500497313856354147
117812034990980493 394082985212671607
821896851840296236 255947510101826050
422579495815431679 738445394838743009
952584027249447301 131591678779711861
804094328392164866 580512445327087...

result:

ok correct (100 test cases)

Test #4:

score: -9
Time Limit Exceeded

input:

100
3
3 3 2
3
4 1 1
4
1 3 4 4
6
4 4 2 3 1 2
4
0 2 1 4
3
0 2 0
7
3 3 1 1 3 4 0
2
0 4
4
1 4 2 3
7
4 0 0 3 2 3 4
4
4 2 0 3
7
0 2 2 1 4 2 4
7
3 0 3 1 2 0 3
4
4 3 1 4
6
2 3 0 1 3 4
5
1 4 0 3 4
5
4 2 0 4 2
3
0 1 2
6
4 1 4 2 0 4
7
4 2 4 3 1 3 1
4
1 4 4 0
2
1 1
6
0 3 3 0 0 4
7
4 3 0 3 3 3 4
4
4 1 1 3
6
2 0 ...

output:


result:


Subtask #2:

score: 0
Time Limit Exceeded

Test #16:

score: 0
Time Limit Exceeded

input:

100
3
3 3 2
3
4 1 1
4
1 3 4 4
6
4 4 2 3 1 2
4
0 2 1 4
3
0 2 0
7
3 3 1 1 3 4 0
2
0 4
4
1 4 2 3
7
4 0 0 3 2 3 4
4
4 2 0 3
7
0 2 2 1 4 2 4
7
3 0 3 1 2 0 3
4
4 3 1 4
6
2 3 0 1 3 4
5
1 4 0 3 4
5
4 2 0 4 2
3
0 1 2
6
4 1 4 2 0 4
7
4 2 4 3 1 3 1
4
1 4 4 0
2
1 1
6
0 3 3 0 0 4
7
4 3 0 3 3 3 4
4
4 1 1 3
6
2 0 ...

output:


result:


Subtask #3:

score: 16
Accepted

Test #34:

score: 16
Accepted
time: 186ms
memory: 4044kb

input:

100000
5
846784256447769304 457696478728961702 128469521648960690 597630796847754190 104256763714529164
5
658897822238868978 472135077337628566 399538027669313322 622703684108675696 425723088635325654
5
917704960887390986 140817562615382054 877934664521057998 782212806618666818 616380973421914538
8
...

output:

104256763714529164 846784256447769304
128469521648960690 457696478728961702
475520510081149234 597630796847754190
293083000188961196 536575653464451712
399538027669313322 425723088635325654
412630558152319488 622703684108675696
472135077337628566 658897822238868978
517667121130497592 565516449788248...

result:

ok correct (100000 test cases)

Test #35:

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

input:

100000
4
132941437397264810 143141501854884272 958712444844113692 341497234016264540
7
923004266892618172 15365813785503270 930609521602302292 819335542601433618 213670074288711286 150311691204302148 244405681344585926
5
371893080714371800 575829750571342010 292988012239447120 115093373296591180 268...

output:

143141501854884272 341497234016264540
132941437397264810 242319367935574406
187630402666419608 958712444844113692
150311691204302148 923004266892618172
536657979048460160 930609521602302292
15365813785503270 213670074288711286
114517944037107278 244405681344585926
179461812690846602 7336337503253812...

result:

ok correct (100000 test cases)

Test #36:

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

input:

100000
4
928198344825292264 690070772109811286 244045206839989604 561025252182682906
3
627239866615848210 42470017740412280 54251562555326842
3
490057757292451598 818062735467254804 348318035919019310
2
551686081736618768 194488231774246450
3
112852023970360962 332810104058707034 451110399052627062
...

output:

244045206839989604 928198344825292264
561025252182682906 586121775832640934
573573514007661920 690070772109811286
54251562555326842 627239866615848210
42470017740412280 340745714585587526
348318035919019310 490057757292451598
818062735467254804 419187896605735454
551686081736618768 19448823177424645...

result:

ok correct (100000 test cases)

Test #37:

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

input:

50000
15
970453612553526824 403854393807928174 722892131244078370 35115189723455662 375191889860000444 915405723947874872 635574780184696680 264400470199418708 859039596531178468 27938184881043946 553805664139227226 876314307095280030 571028682295683456 30435765695090076 81051167961127742
20
7987413...

output:

30435765695090076 264400470199418708
147418117947254392 375191889860000444
571028682295683456 635574780184696680
603301731240190068 859039596531178468
731170663885684268 915405723947874872
27938184881043946 35115189723455662
31526687302249804 970453612553526824
81051167961127742 261305003903627418
4...

result:

ok correct (50000 test cases)

Test #38:

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

input:

50000
20
998788559176849620 191593882411529926 342711646561735406 56435783243285828 213144199738872896 552932543009462260 862655508602678778 197769932466201968 649107231900330578 606332158266321414 679519095246181928 69228654018660218 907522706303602556 706594708190768848 317996892998797510 98299001...

output:

56435783243285828 197769932466201968
213144199738872896 280145788708142508
552932543009462260 679519095246181928
706594708190768848 801974222113409124
907522706303602556 982990013470682716
945256359887142636 998788559176849620
69228654018660218 82951860797867962
76090257408264090 127102857854743898
...

result:

ok correct (50000 test cases)

Test #39:

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

input:

50000
19
687533614023914694 738663892302361454 628044408557611320 475365328934162610 242048409095362442 254414508714647088 415287407545536222 333427085181162020 691789987581261114 501496830456417768 370865072857248388 610878478005084624 460491699469405256 995621599317911412 72184531803437802 5221300...

output:

254414508714647088 333427085181162020
370865072857248388 435000735991149736
460491699469405256 501496830456417768
480994264962911512 522130070969414520
501562167966163016 610878478005084624
556220322985623820 628044408557611320
72184531803437802 242048409095362442
157116470449400122 2939207969479045...

result:

ok correct (50000 test cases)

Test #40:

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

input:

30000
25
701453932981408346 465306500019836282 792774089369512740 928134668660137906 489548012753296822 563069662510759842 456553328586506700 752651620972947846 610563120623014800 946872198162810216 382124190056540228 528408240467204940 156080508230960224 755279683495886594 353003950140523154 726814...

output:

156080508230960224 264865148139811024
210472828185385624 331430792491044112
270951810338214868 382124190056540228
326538000197377548 456553328586506700
391545664391942124 528408240467204940
459976952429573532 610563120623014800
671093790812801428 759546580482469476
715320185647635452 792774089369512...

result:

ok correct (30000 test cases)

Test #41:

score: 0
Accepted
time: 262ms
memory: 3736kb

input:

30000
24
802553849623129746 211707666543464912 78106851365388652 41150834245659428 824295231323480318 65220471583082028 504011063830422278 582465764474213950 653316240753155704 254391730000013712 73470169815090336 70058062306145696 320805890715812130 762434076887201766 107191591092647094 66623182252...

output:

41150834245659428 65220471583082028
53185652914370728 66623182252282192
59904417583326460 70058062306145696
73470169815090336 78106851365388652
211707666543464912 254391730000013712
233049698271739312 317895789993303868
476075710640293640 653316240753155704
564695975696724672 684143755784659968
6244...

result:

ok correct (30000 test cases)

Test #42:

score: 0
Accepted
time: 265ms
memory: 4080kb

input:

30000
27
457692759396051910 105542225399435134 28952855744712754 551775949854678384 243201017518706110 830727952675976422 770508119165800012 202072001288194376 842102259870000526 184524967708115324 636362069740656520 654459612358466674 183209892432401444 100513548134942846 72707763558771580 42597951...

output:

72707763558771580 80157746650466448
88106760930326920 154087971015879464
121097365973103192 183209892432401444
184524967708115324 202072001288194376
425979517791387492 551775949854678384
636362069740656520 770508119165800012
932151312699294980 935240383379985812
933695848039640396 938142428437837892...

result:

ok correct (30000 test cases)

Test #43:

score: 0
Accepted
time: 572ms
memory: 24332kb

input:

100
365633
240280625535601202 938026129049958522 147115906397155306 652580989323075650 725975096118295602 205776298062652394 601103849421971138 331987681752388762 840580362429635958 835259996207496842 119358021292888398 319502650126227206 963133797479057582 879470558738716974 741484002023142690 3370...

output:

1224294508562 3529522101850
2376908305206 7968875390110
5172891847658 9137977473786
7155434660722 9569483208450
8362458934586 9877875386422
11309686212834 14694421398306
13002053805570 15836622505222
9120167160504 14419338155396
11769752657950 16404261255130
20436232217466 25102205290010
22769218753...

result:

ok correct (100 test cases)

Test #44:

score: 0
Accepted
time: 620ms
memory: 28892kb

input:

100
468798
784219641558971418 868193736931466770 709669653094040434 820342537947112058 551143489403660526 267279653811163658 370522601251248390 368960240455457934 377406818992348662 446571520515917398 203417725700526758 781465163407686018 793863659816666930 689102809204233742 460833182899194594 8845...

output:

306634195686 839909402466
1954818138646 2000236587010
573271799076 1977527362828
5968312633518 6905526210190
6436919421854 8294507717898
1275399580952 7365713569876
4320556575414 9513716722110
6917136648762 13778152549958
14347223427250 18916736754538
16631980090894 24960970249278
20796475170086 347...

result:

ok correct (100 test cases)

Test #45:

score: 0
Accepted
time: 536ms
memory: 22960kb

input:

100
335003
576606818757903242 39138102231712338 101565358810296722 500967049719563958 60093483316193590 435418544638688670 883896893287765898 482015906798694930 208166390296394766 603169642587608970 697598340090102702 37116072285605102 692409274069565602 359039270687175358 598214522887322026 9588135...

output:

2040433739546 6592524639274
4316479189410 10567174034114
7441826611762 15470717418950
11456272015356 494765326766777336
22543957320962 22606300576930
22575128948946 24649258563034
23612193755990 25101088583370
32590029487838 32888945987010
24356641169680 32739487737424
37906765677958 42334817917302
...

result:

ok correct (100 test cases)

Subtask #4:

score: 0
Wrong Answer

Test #46:

score: 0
Wrong Answer
time: 86ms
memory: 11408kb

input:

100
211957
911918942087402387 344230223346742784 16289402153237664 528890583619159010 886281719684850237 865484734102017297 321851390502278959 754268375474197153 237414161302130571 135637002716682378 824412491959977735 162505521049217610 246319278060116103 666703181591704279 650875500699154233 96397...

output:

945205410564117397 506489830890255987
705650240624406006 441192426604140330
186919616587700128 605645018889792892
725847620727186692 396282317738746510
298912059620894683 561064969232966601
573421333614273168 429988514426930642
651525166943680707 480095448722632795
311199887286079004 483276654307090...

result:

wrong answer Integer -1 violates the range [0, 10^18] (test case 1)