QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#507146#6667. Prosjek_Luminous0 91ms6296kbC++171.1kb2024-08-06 11:40:292024-08-06 11:40:29

Judging History

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

  • [2024-08-06 11:40:29]
  • 评测
  • 测评结果:0
  • 用时:91ms
  • 内存:6296kb
  • [2024-08-06 11:40:29]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+10;
mt19937 rnd(time(0));
vector<ll> t[2];
vector<pair<ll,ll>> v;
ll a[N];
int n,T;
ll Pop(int x){
	ll a=t[x].back();
	t[x].pop_back();
	return a;
}
void work(int j){
	ll x=Pop(j),y=Pop(j),z=(x+y)>>1;
	v.push_back({x,y});
	t[z&1].push_back(z);
}
bool okok(){
	v.clear();
	for(int i=0;i<2;i++) t[i].clear();
	for(int i=1;i<=n;i++) t[a[i]&1].push_back(a[i]);
	for(int i=1;i<n;i++){
		if(t[0].size()==1 && t[1].size()==1) return 0;
		int p=rnd()&1;
		for(int j=0;j<2;j++)
			if(t[j^p].size()>1){work(j^p);break;}
	}
	for(auto k:v) printf("%lld %lld\n",k.first,k.second);
	return 1;
}
int main(){
//	freopen("meow.in","r",stdin);
//	freopen("meow.out","w",stdout);
	scanf("%d",&T);
	while(T--){
		scanf("%d",&n);
		bool even=true;
		for(int i=1;i<=n;i++){
			scanf("%lld",&a[i]);
			if(a[i]%2) even=false;
		}
		if(!even || T>100) continue;
		int flag=0;
		for(int i=1;i<=500;i++){
			shuffle(a+1,a+n+1,rnd);
			if(okok()) {flag=1;break;}
		}
		if(!flag) puts("-1");
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3936kb

input:

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

output:

306233065082806734 841634384550345462
573933724816576098 880394701391566042
163385290771965010 342024539797259018
252704915284612014 930733700403006064
327387894930879280 290755794136321364
309071844533600322 90631795972271738
199851820252936030 734043298171153452
574824673454037818 6579819885178465...

result:

wrong answer there's no 306233065082806734 in the current set (test case 1)

Subtask #2:

score: 0
Wrong Answer

Test #16:

score: 0
Wrong Answer
time: 0ms
memory: 3840kb

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:

0 0
0 2
4 0
0 2
4 4
4 2
3 1
0 0
0 4
2 4
0 4
2 2
2 4
2 4
4 0
2 4
0 4
2 0
1 3
2 0
4 2
4 2
3 3
0 2
1 3
4 0
0 0
0 4
0 0
0 0
0 0
0 2
2 4
2 0
1 3

result:

wrong answer there's no 0 in the current set (test case 1)

Subtask #3:

score: 0
Wrong Answer

Test #34:

score: 0
Wrong Answer
time: 61ms
memory: 4028kb

input:

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

output:

740817534945924458 87580144448652878
414198839697288668 288297222354704974
99378793693662270 563225317725693454
331302055709677862 771250330670969770
551276193190323816 714571681333388162
536164021542649412 533614539670366470
534889280606507941 632923937261855989
583906608934181965 35124803102599682...

result:

wrong answer there's no 740817534945924458 in the current set (test case 1)

Subtask #4:

score: 0
Wrong Answer

Test #46:

score: 0
Wrong Answer
time: 91ms
memory: 6296kb

input:

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

output:

749318179341718328 719305379065820542
978135283799375274 742536530921432840
860335907360404057 734311779203769435
749857132494344162 311961926661567072
30159557389233966 473540720761303878
469213583472960 607264137430136784
303866675506804872 277401424002240658

result:

wrong output format Unexpected end of file - int64 expected (test case 1)