QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#326116 | #2351. Lost in Transfer | duongnc000 | 0 | 0ms | 3528kb | C++20 | 2.9kb | 2024-02-12 12:17:24 | 2024-02-12 12:17:25 |
answer
/*
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2,fma,bmi,bmi2,sse4.2,popcnt,lzcnt")
*/
#include <bits/stdc++.h>
#define taskname ""
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define i64 long long
#define pb push_back
#define ff first
#define ss second
#define isz(x) (int)x.size()
using namespace std;
const int mxN = 2e5 + 5;
const int mod = 1e9 + 7;
const i64 oo = 1e18;
void transmit() {
int tests; cin >> tests;
while (tests--) {
int n; cin >> n;
vector<int> a(n);
int sxor = 0;
for (int i = 0; i < n; ++i) {
cin >> a[i];
sxor ^= a[i];
}
sort(all(a));
int l = 0, r = n;
for (int i = 8; i >= 0; --i) {
if (sxor >> i & 1) cout << a[r - 2] << " " << a[r - 1] << " ", r -= 2;
else cout << a[l + 1] << " " << a[l] << " ", l += 2;
}
for (int i = l; i < r; ++i) cout << a[i] << " ";
cout << "\n";
}
}
void recover() {
int tests; cin >> tests;
while (tests--) {
int n; cin >> n;
vector<int> a(n);
int cxor = 0;
for (int i = 0; i < n; ++i) {
cin >> a[i];
cxor ^= a[i];
cout << a[i] << " ";
}
auto na = a;
for (int i = 0; i < n; ++i) a[i] = lower_bound(all(na), a[i]) - na.begin();
int l = 0, r = n, ptr = 0, sxor = 0;
for (int i = 8; i >= 0; --i) {
if (a[ptr] == l) {
sxor = sxor << 1;
++ptr, ++l;
}
else if (a[ptr] == l + 1) {
sxor = sxor << 1;
ptr += 2, l += 2;
}
else if (a[ptr] == r - 1) {
sxor = sxor << 1 | 1;
--ptr, --r;
}
else if (a[ptr] == r - 2) {
sxor = sxor << 1 | 1;
ptr -= 2, r -= 2;
}
}
sxor ^= cxor;
if (sxor) cout << sxor << "\n";
else cout << "\n";
}
}
string name;
void solve() {
cin >> name;
if (name == "transmit") transmit();
else recover();
}
signed main() {
#ifndef CDuongg
if(fopen(taskname".inp", "r"))
assert(freopen(taskname".inp", "r", stdin)), assert(freopen(taskname".out", "w", stdout));
#else
freopen("bai3.inp", "r", stdin);
freopen("bai3.out", "w", stdout);
auto start = chrono::high_resolution_clock::now();
#endif
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1; //cin >> t;
while(t--) solve();
#ifdef CDuongg
auto end = chrono::high_resolution_clock::now();
cout << "\n"; for(int i = 1; i <= 100; ++i) cout << '=';
cout << "\nExecution time: " << chrono::duration_cast<chrono::milliseconds> (end - start).count() << "[ms]" << endl;
cout << "Check array size pls sir" << endl;
#endif
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3528kb
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:
58 32 97 87 459 467 405 426 388 403 374 378 330 333 296 325 267 271 98 99 32 26 68 61 100 86 494 495 120 118 451 481 339 444 136 125 281 292 150 192
input:
recover 2 19 58 32 97 87 459 467 405 426 388 403 374 378 330 333 296 325 267 271 98 19 32 26 68 61 86 494 495 120 118 451 481 339 444 136 125 281 292 150 192
output:
58 32 97 87 459 467 405 426 388 403 374 378 330 333 296 325 267 271 98 28 32 26 68 61 86 494 495 120 118 451 481 339 444 136 125 281 292 150 192 73
result:
wrong answer incorrect answer. (test case 1)