QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#861502 | #2351. Lost in Transfer | khoaduy | 0 | 2ms | 3712kb | C++20 | 2.8kb | 2025-01-18 17:46:02 | 2025-01-18 17:46:13 |
answer
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
string role;
cin >> role;
if(role=="transmit"){
int t;
cin >> t;
while(t--){
int n;
cin >> n;
int a[n];
int sum=0;
for(int i=0;i<n;i++){
cin >> a[i];
sum^=a[i];
}
sort(a,a+n);
string send="";
for(int i=0;i<9;i++){
if(sum&(1<<i)){
send+='1';
}
else{
send+='0';
}
}
while(send.size()+9<n-1){
send+='0';
}
for(int i=8;i>=0;i--){
if(sum&(1<<i)){
send+='1';
}
else{
send+='0';
}
}
vector<int> b;
int ptr1,ptr2=0;
for(int i=0;i<send.size();i++){
if(send[i]=='1'){
ptr2++;
}
}
ptr1=ptr2;
ptr2++;
b.push_back(a[ptr1]);
ptr1--;
for(int i=0;i<send.size();i++){
if(send[i]=='0'){
b.push_back(a[ptr2]);
ptr2++;
}
else{
b.push_back(a[ptr1]);
ptr1--;
}
}
for(int i=0;i<b.size();i++){
cout << b[i] << ' ';
}
cout << endl;
}
}
else{
int t;
cin >> t;
while(t--){
int n;
cin >> n;
string send="";
int curr=0,sum=0,temp=0;
int last=-1;
vector<int> a;
for(int i=0;i<n;i++){
int x;
cin >> x;
curr^=x;
a.push_back(x);
if(i>0){
if(last<x){
send+='0';
}
else{
send+='1';
}
}
last=x;
}
for(int i=0;i<9;i++){
temp=temp*2+(send[i]-'0');
}
sum=max(sum,temp);
temp=0;
for(int i=send.size()-1;i>=send.size()-9;i--){
temp=temp*2+(send[i]-'0');
}
sum=max(sum,temp);
if(curr!=sum){
a.push_back(curr^sum);
}
for(int i=0;i<a.size();i++){
cout << a[i] << ' ';
}
cout << endl;
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 3712kb
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:
388 378 374 333 330 325 296 271 403 405 426 459 467 267 99 98 97 87 58 32 125 120 136 118 100 150 86 192 281 292 339 444 451 481 68 494 61 32 495 26
input:
recover 2 19 388 378 374 333 330 325 296 271 403 405 426 459 467 267 99 98 97 87 58 19 125 120 136 118 150 86 192 281 292 339 444 451 481 68 494 61 32 495 26
output:
388 378 374 333 330 325 296 271 403 405 426 459 467 267 99 98 97 87 58 419 125 120 136 118 150 86 192 281 292 339 444 451 481 68 494 61 32 495 26 289
result:
wrong answer incorrect answer. (test case 1)