QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#768580#6667. Prosjekzhaohaikun0 123ms3836kbC++231.9kb2024-11-21 12:36:472024-11-21 12:36:47

Judging History

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

  • [2024-11-21 12:36:47]
  • 评测
  • 测评结果:0
  • 用时:123ms
  • 内存:3836kb
  • [2024-11-21 12:36:47]
  • 提交

answer

// MagicDark
#include <bits/stdc++.h>
#define int long long
#define debug cerr << "\33[32m[" << __LINE__ << "]\33[m "
#define SZ(x) ((int) x.size() - 1)
#define all(x) x.begin(), x.end()
#define ms(x, y) memset(x, y, sizeof x)
#define F(i, x, y) for (int i = (x); i <= (y); i++)
#define DF(i, x, y) for (int i = (x); i >= (y); i--)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template <typename T> T& chkmax(T &x, T y) {return x = max(x, y);}
template <typename T> T& chkmin(T &x, T y) {return x = min(x, y);}
template <typename T> T& read(T &x) {
	x = 0; int f = 1; char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = - f;
	for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
	return x *= f;
}
const int N = 1e6 + 10;
int n, a[N];
vector <pair <int, int>> ans;
void zhk() {
	ans.clear();
	read(n);
	vector <int> g[2];
	F(i, 1, n) read(a[i]), g[a[i] & 1].push_back(a[i]);
	F(i, 0, 1) sort(all(g[i]));
	if (g[0].empty() || g[1].empty()) {
		vector <int> w[2];
		auto ins = [&] (int x) {
			w[(x >> 1) & 1].push_back(x);
		};
		F(i, 1, n) ins(a[i]);
		while (w[0].size() >= 2 || w[1].size() >= 2) {
			if (w[0].size() >= 2) {
				int x = w[0][SZ(w[0]) - 1], y = w[0][SZ(w[0])];
				ans.emplace_back(x, y);
				ins((x + y) / 2);
				w[0].pop_back();
				w[0].pop_back();
			}
			if (w[1].size() >= 2) {
				int x = w[1][SZ(w[1]) - 1], y = w[1][SZ(w[1])];
				ans.emplace_back(x, y);
				ins((x + y) / 2);
				w[1].pop_back();
				w[1].pop_back();
			}
		}
		if (w[0].size() && w[1].size()) ans.emplace_back(w[0][0], w[1][0]);
	} else {
		// F(i, )
	}
	assert(ans.size() == n - 1);
	// cout << ans.size() << '\n';
	for (auto [i, j]: ans) {
		assert((i + j) % 2 == 0);
		cout << i << ' ' << j << '\n';
	}
}
signed main() {
	int _ = 1;
	cin >> _;
	while (_--) zhk();
	return 0;
}
/* why?
*/

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Runtime Error

Test #1:

score: 0
Runtime Error

input:

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

output:


result:


Subtask #2:

score: 0
Runtime Error

Test #16:

score: 0
Runtime Error

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: 0
Wrong Answer

Test #34:

score: 0
Wrong Answer
time: 123ms
memory: 3836kb

input:

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

output:

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

result:

wrong answer there's no 622703684108675696 in the current set (test case 2)

Subtask #4:

score: 0
Runtime Error

Test #46:

score: 0
Runtime Error

input:

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

output:


result: