QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#20409#2351. Lost in Transferlinmuhan#0 0ms0kbC++201.5kb2022-02-16 07:38:552023-01-17 09:29:46

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-17 09:29:46]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2022-02-16 07:38:55]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int N = 120;
string sys; int T, n, a[N], S;
int BIT = 8;
bool pd[N];
int main () {
	cin >> sys;
	if (sys[0] == 't') {
		cin >> T;
		while (T --) {
			cin >> n; for (int i=1;i<=n;i++) cin >> a[i];
			S = 0;
			for (int i=1;i<=n;i++) S ^= a[i];
			sort (a + 1, a + n + 1); int l = 1, r = n;
			for (int i=0;i<=8;i++) {
				if (S & (1 << i)) {
					cout << a[l] << " < " << a[l + 1] << " < ";
					l += 2;
				} else {
					cout << a[r] << " > " << a[r - 1] << " > ";
					r -= 2;
				}
			}
			for (int i=l;i<=r;i++) cout << a[i] << " ";
			cout << endl;
		}
	} else {
		cin >> T;
		while (T --) {
			cin >> n; for (int i=1;i<=n;i++) cin >> a[i];
			for (int i=1;i<=18;i++) if (a[i] < a[i + 1]) pd[i] = 1; else pd[i] = 0;
			int pos = 0, m = 18; S = 0;
			for (int l=1,r;l<=m;l=r+1) {
				r = l; while (pd[r] == pd[l] && r <= m) r ++; r --;
				if ((r - l + 1) % 2 == 1) {
					for (int i=m;i>=r+1;i--) pd[i] = pd[i - 1];
					pd[r + 1] = pd[l]; r ++;
					int len = r - l + 1;
					while (len) {
						S |= (pd[l] << pos);
						len -= 2; pos ++;
					}
				} else {
					int len = r - l + 1;
					while (len) {
						S |= (pd[l] << pos);
						len -= 2; pos ++;
					}
				}
			}
			int TS = 0;
			for (int i=1;i<=n;i++) TS ^= a[i];
			TS ^= S;
			if (! TS) {
				for (int i=1;i<=n;i++) cout << a[i] << " "; puts ("");
			} else {
				for (int i=1;i<=n;i++) cout << a[i] << " "; cout << TS << " "; puts ("");
			}
		}
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer

input:

transmit
2
20 97 388 459 467 32 99 98 296 403 325 330 271 87 333 378 267 405 58 426 374
20 125 481 451 150 495 136 444 192 118 26 68 281 120 61 494 339 86 292 100 32

output:

32 < 58 < 87 < 97 < 98 < 99 < 267 < 271 < 296 < 325 < 330 < 333 < 374 < 378 < 467 > 459 > 426 > 405 > 388 403 
26 < 32 < 495 > 494 > 61 < 68 < 86 < 100 < 481 > 451 > 118 < 120 < 444 > 339 > 292 > 281 > 192 > 150 > 125 136 

input:


output:


result:

wrong output format Expected integer, but "<" found (test case 1)