QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#19961 | #2351. Lost in Transfer | wxp# | 0 | 4ms | 3828kb | C++20 | 1.3kb | 2022-02-14 14:09:26 | 2023-01-17 09:26:32 |
Judging History
answer
#include<bits/stdc++.h>
#define rep(i,x,y) for(int i=x;i<=y;++i)
#define per(i,x,y) for(int i=x;i>=y;--i)
#define lon long long
using namespace std;
const int n7=105;
int n,T,a[n7];
int rd(){
int shu=0;bool fu=0;char ch=getchar();
while( !isdigit(ch) ){if(ch=='-')fu=1;ch=getchar();}
while( isdigit(ch) )shu=(shu<<1)+(shu<<3)+ch-'0',ch=getchar();
return fu?-shu:shu;
}
namespace Task1{
void solve(){
T=rd();
while(T--){
n=rd();int s=0;
rep(i,1,n)a[i]=rd(),s=(s+a[i])%501;
sort(a+1,a+n+1);
int l=0,r=n+1;bool las=0;
per(i,8,0){
if( s&(1<<i) )printf("%d %d ",a[l+1],a[l+2]),l=l+2,las=1;
else printf("%d %d ",a[r-1],a[r-2]),r=r-2,las=0;
}
if(las)printf("%d ",a[l+1]),l++;
else printf("%d ",a[r-1]),r--;
rep(i,l+1,r-1)printf("%d ",a[i]);
putchar('\n');
}
}
}
namespace Task2{
void solve(){
T=rd();
while(T--){
n=rd();int s=0;
rep(i,1,n)a[i]=rd(),s=(s+a[i])%501;
int s0=0;
for(int i=1;i<18;i=i+2){
int x=(a[i]<a[i+1]);
if( (a[i]<a[i+1])^(a[i+1]<a[i+2]) )i--;
s0=(s0*2+x)%501;
}
rep(i,1,n)printf("%d ",a[i]);
if(s0^s)printf("%d ",abs(s0-s));
putchar('\n');
}
}
}
int main(){
char sys[9];
scanf("%s",sys);
if(sys[0]=='t')Task1::solve();
else Task2::solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 4ms
memory: 3828kb
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:
467 459 426 405 32 58 403 388 87 97 378 374 333 330 98 99 325 296 271 267 26 32 61 68 86 100 118 120 495 494 481 451 444 339 125 136 150 192 281 292
input:
recover 2 19 467 459 426 405 32 58 403 388 87 97 378 374 333 330 98 99 325 296 271 19 26 32 61 68 100 118 120 495 494 481 451 444 339 125 136 150 192 281 292
output:
467 459 426 405 32 58 403 388 87 97 378 374 333 330 98 99 325 296 271 234 26 32 61 68 100 118 120 495 494 481 451 444 339 125 136 150 192 281 292 86
result:
wrong answer incorrect answer. (test case 1)