QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#22449 | #2351. Lost in Transfer | WhybullYMe# | 0 | 0ms | 3892kb | C++20 | 1.9kb | 2022-03-09 18:30:52 | 2023-01-17 09:35:56 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ri int
typedef long long ll;
const int maxn=1e5+10;
template<class T>inline bool ckmin(T &x,const T &y){return x>y?x=y,1:0;}
template<class T>inline bool ckmax(T &x,const T &y){return x<y?x=y,1:0;}
template<class T>inline void clear(T *arr,int siz,int val=0){memset(arr,val,sizeof(T)*(siz+1));}
map<vector<int>,int>id;
vector<vector<int>>p;
inline void init(){
vector<int>a(6);
iota(a.begin(),a.end(),0);
do id[a]=p.size(),p.push_back(a);while(next_permutation(a.begin(),a.end()));
}
inline vector<int> encode(vector<int> a){
sort(a.begin(),a.end());
ri xsum=0;
for(ri i:a)xsum^=i;
for(ri i=0;i<a.size();i+=6){
if((i>>6)&1)reverse(a.begin()+i,a.begin()+min(i+6,(int)a.size()));
if(i+6<=a.size()){
vector<int>b(6),&c=p[xsum];
for(ri j=0;j<6;++j)b[j]=a[i+c[j]];
for(ri j=0;j<6;++j)a[i+j]=b[j];
}
}
return a;
}
inline int get_id(const vector<int> &a,int p,bool t){
typedef pair<int,int> pii;
#define fi first
#define se second
vector<pii>b(6);
for(ri i=0;i<6;++i)b[i]={a[p+i],i};
if(t)sort(b.begin(),b.end(),greater<pii>());
else sort(b.begin(),b.end());
vector<int>c(6);
for(ri i=0;i<6;++i)c[b[i].se]=i;
return id[c];
}
inline vector<int>decode(vector<int> a){
if(encode(a)==a)return a;
ri B=(a.size()+1)/6;
for(ri i=0;i<B;++i){
ri lst=-1;
for(ri j=0;j<B;++j)
if(i!=j){
ri cur=get_id(a,j*6-(i<j),j&1);
if(lst==-1)lst=cur;
else if(cur!=lst)goto skip;
}
for(ri i:a)lst^=i;
a.push_back(lst);
return a;
skip:;
}
ri xsum=get_id(a,0,0);
for(ri i:a)xsum^=i;
a.push_back(xsum);
return a;
}
char s[123];
int n,t_case;
int main(){
init();
scanf("%s%d",s+1,&t_case);
while(t_case--){
scanf("%d",&n);
vector<int>a(n);
for(ri &i:a)scanf("%d",&i);
if(s[1]=='t')a=encode(a);
else a=decode(a);
for(ri i:a)printf("%d ",i);
printf("\n");
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3892kb
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 99 98 271 267 325 296 333 330 378 374 403 388 426 405 459 467 26 61 100 68 86 32 118 125 192 136 150 120 281 339 481 444 451 292 494 495
input:
recover 2 19 58 32 97 87 99 98 271 267 325 296 333 330 378 374 403 388 426 405 459 19 26 61 100 68 32 118 125 192 136 150 120 281 339 481 444 451 292 494 495
output:
58 32 97 87 99 98 271 267 325 296 333 330 378 374 403 388 426 405 459 467 26 61 100 68 32 118 125 192 136 150 120 281 339 481 444 451 292 494 495 93
result:
wrong answer incorrect answer. (test case 2)