QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#116997#6667. ProsjekHe_Ren#0 140ms10196kbC++17794b2023-06-30 12:05:292024-05-31 18:36:50

Judging History

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

  • [2024-05-31 18:36:50]
  • 评测
  • 测评结果:0
  • 用时:140ms
  • 内存:10196kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-30 12:05:29]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN = 1e6 + 5;

ll a[MAXN];

void solve(void)
{
	int n;
	scanf("%d",&n);
	for(int i=1; i<=n; ++i)
		scanf("%lld",&a[i]);
	
	vector<ll> vec[4];
	for(int i=1; i<=n; ++i)
		vec[a[i] % 4].emplace_back(a[i]);
	
	auto upd = [&] (int i,int j)
	{
		ll x = vec[i].back(); vec[i].pop_back();
		ll y = vec[j].back(); vec[j].pop_back();
		printf("%lld %lld\n",x,y);
		
		assert((x + y) % 2 == 0);
		
		ll z = (x + y) / 2;
		vec[z % 4].emplace_back(z);
	};
	while(vec[2].size() >= 2) upd(2, 2);
	while(vec[0].size() >= 2) upd(0, 0);
	while(vec[0].size() && vec[2].size()) upd(0, 2);
}

int main(void)
{
	int T;
	scanf("%d",&T);
	while(T--) solve();
	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: 4044kb

input:

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

output:

222072661880779376 19206582949872932
115754892157516718 53191076581680214
804173775829453588 445068618251612752
209088712310207988 624621197040533170
199941674506573816 341612949433488278
18362969272825184 829133522612010568
423748245942417876 622340535259594554
171005241618509960 596920666938163548...

result:

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

Subtask #2:

score: 0
Wrong Answer

Test #16:

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

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:

4 4
2 2
4 4
4 2
4 0
0 0
0 2
0 4
4 0
4 2
4 0
0 4
0 4
2 2
2 2
4 4
4 0
0 0
0 2
4 4
4 0
4 0
4 2
2 2
4 0
4 2
0 2
4 0
4 4
4 2
4 4
4 2
0 4
4 2
4 0
0 0
0 2
4 0
4 2
4 4
4 0
0 0
0 0
2 2
0 2
2 2
4 0
0 4
0 4
4 2
0 2
0 0
0 2
4 4
4 0
0 2
2 2
4 0
4 4
0 2
0 4
4 2
4 4
2 2
4 2
0 4
4 4
4 0
4 2
4 4
4 0
0 0
0 2
4 0
4 4
...

result:

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

Subtask #3:

score: 0
Wrong Answer

Test #34:

score: 0
Wrong Answer
time: 137ms
memory: 3872kb

input:

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

output:

597630796847754190 128469521648960690
363050159248357440 104256763714529164
846784256447769304 233653461481443302
425723088635325654 399538027669313322
472135077337628566 658897822238868978
565516449788248772 412630558152319488
622703684108675696 489073503970284130
616380973421914538 782212806618666...

result:

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

Subtask #4:

score: 0
Wrong Answer

Test #46:

score: 0
Wrong Answer
time: 140ms
memory: 10196kb

input:

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

output:

543486620620520822 970719751816939554
838096108401048706 173917880031771874
506006994216410290 895993850227350770
701000422221880530 123398455791284862
820792205633830134 70763732070453590
445777968852141862 503302934631784774
474540451741963318 704778622645585118
589659537193774218 9064815545332896...

result:

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