QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#22330 | #2351. Lost in Transfer | Qyc_AK_NOI2022# | 0 | 4ms | 3332kb | C++20 | 7.0kb | 2022-03-09 15:31:49 | 2023-01-17 09:31:10 |
Judging History
answer
#include<cstdio>
#include<iostream>
#include<cstring>
#include<queue>
#include<stack>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<random>
#include<chrono>
#include<deque>
#include<cassert>
#include<cstdlib>
#include<cmath>
#include<ctime>
#include<vector>
#define fi first
#define se second
#define pb push_back
#define mp std::make_pair
#define ulf Useful_little_function
#define abs ccf
#define inline __attribute__((always_inline))inline
#define INF (0x3f3f3f3f)
#define INT_INF (2147483647)
#define LLINF (0x3f3f3f3f3f3f3f3fll)
#define LL_INF (9223372036854775807)
#define memset __builtin_memset
#define popcount __builtin_popcount
std::mt19937 rnd(std::chrono::system_clock::now().time_since_epoch().count());
typedef long long ll;
typedef std::pair<int,int> pii;
typedef unsigned int uint;
typedef unsigned long long ull;
inline void file(){freopen(".in","r",stdin);freopen(".out","w",stdout);}
namespace IO{
#define BUF_SIZE (1<<16)
#define OUT_SIZE (1<<16)
bool IOerror=0;
inline char nc(){static char buf[BUF_SIZE],*p1=buf+BUF_SIZE,*pend=buf+BUF_SIZE;if(p1==pend){p1=buf;pend=buf+fread(buf,1,BUF_SIZE,stdin);if(pend==p1)return IOerror=1,-1;}return *p1++;}
inline bool blank(char ch){return ch==' '||ch=='\n'||ch=='\r'||ch=='\t';}
inline void read(int &x){bool sign=0;char ch=nc();x=0;for(;blank(ch);ch=nc());if(IOerror)return;if(ch=='-')sign=1,ch=nc();for(;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';if(sign)x=-x;}
inline void read(ll &x){bool sign=0;char ch=nc();x=0;for(;blank(ch);ch=nc());if(IOerror)return;if(ch=='-')sign=1,ch=nc();for(;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';if(sign)x=-x;}
inline void read(double &x){bool sign=0;char ch=nc();x=0;for(;blank(ch);ch=nc());if(IOerror)return;if(ch=='-')sign=1,ch=nc();for(;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';if(ch=='.'){double tmp=1;ch=nc();for(;ch>='0'&&ch<='9';ch=nc())tmp/=10.0,x+=tmp*(ch-'0');}if(sign)x=-x;}
inline void read(char *s){char ch=nc();for(;blank(ch);ch=nc());if(IOerror)return;for(;!blank(ch)&&!IOerror;ch=nc())*s++=ch;*s=0;}
inline void read(char &c){for(c=nc();blank(c);c=nc());if(IOerror){c=-1;return;}}
struct Ostream_fwrite{
char *buf,*p1,*pend;
Ostream_fwrite(){buf=new char[BUF_SIZE];p1=buf;pend=buf+BUF_SIZE;}
inline void out(char ch){if(p1==pend){fwrite(buf,1,BUF_SIZE,stdout);p1=buf;}*p1++=ch;}
inline void print(int x){static char s[15],*s1;s1=s;if(!x)*s1++='0';if(x<0)out('-'),x=-x;while(x)*s1++=x%10+'0',x/=10;while(s1--!=s)out(*s1);}
inline void println(int x){print(x);out('\n');}
inline void print(ll x){static char s[25],*s1;s1=s;if(!x)*s1++='0';if(x<0)out('-'),x=-x;while(x)*s1++=x%10+'0',x/=10;while(s1--!=s)out(*s1);}
inline void println(ll x){print(x);out('\n');}
inline void print(double x,int y){//y<18
static ll mul[]={1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000,10000000000LL,100000000000LL,1000000000000LL,10000000000000LL,100000000000000LL,1000000000000000LL,10000000000000000LL,100000000000000000LL};
if(x<-1e-12)out('-'),x=-x;x*=mul[y];ll x1=(ll)floor(x);if(x-floor(x)>=0.5)++x1;ll x2=x1/mul[y],x3=x1-x2*mul[y];print(x2);if(y>0){out('.');for(size_t i=1;i<y&&x3*mul[i]<mul[y];out('0'),++i);print(x3);}
}
inline void println(double x,int y){print(x,y);out('\n');}
inline void print(char *s){while(*s)out(*s++);}
inline void println(char *s){while(*s)out(*s++);out('\n');}
inline void flush(){if(p1!=buf){fwrite(buf,1,p1-buf,stdout);p1=buf;}}
~Ostream_fwrite(){flush();}
}Ostream;
inline void print(int x){Ostream.print(x);}
inline void println(int x){Ostream.println(x);}
inline void print(char x){Ostream.out(x);}
inline void println(char x){Ostream.out(x);Ostream.out('\n');}
inline void print(ll x){Ostream.print(x);}
inline void println(ll x){Ostream.println(x);}
inline void print(double x,int y){Ostream.print(x,y);}
inline void println(double x,int y){Ostream.println(x,y);}
inline void print(char *s){Ostream.print(s);}
inline void println(char *s){Ostream.println(s);}
inline void println(){Ostream.out('\n');}
inline void flush(){Ostream.flush();}
#undef OUT_SIZE
#undef BUF_SIZE
}using namespace IO;
namespace Little_function{
inline int abs(int x){return x<0?-x:x;}
inline ll abs(ll x){return x<0?-x:x;}
inline double abs(double x){return x<0?-x:x;}
inline int max(const int &a,const int &b){return a>b?a:b;}
inline ll max(const ll &a,const ll &b){return a>b?a:b;}
inline double max(const double &a,const double &b){return a>b?a:b;}
inline int min(const int &a,const int &b){return a<b?a:b;}
inline ll min(const ll &a,const ll &b){return a<b?a:b;}
inline double min(const double &a,const double &b){return a<b?a:b;}
inline void swap(int &x,int &y){x^=y^=x^=y;}
inline void swap(ll &x,ll &y){x^=y^=x^=y;}
inline void swap(double &x,double &y){double t=x;x=y,y=t;}
inline int madd(const int &a,const int &b,const int &p){return (a+b)%p;}
inline int mdel(const int &a,const int &b,const int &p){return (a-b<0?a-b+p:a-b);}
int gcd(int a,int b){return !b?a:gcd(b,a%b);}
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
}using namespace Little_function;
const int N=300+13;
int n,a[N],d[7];
inline void work(int *a){
int b[7],c[7];
for(int i=1;i<=6;++i) b[i]=a[i];
std::sort(b+1,b+7);
for(int i=1;i<=6;++i){
int x=std::lower_bound(b+1,b+7,a[i])-b;
c[d[x]]=a[i];
}
for(int i=1;i<=6;++i) a[i]=c[i];
}
int m;
inline int calc(int *a){
int b[7],c[7];
for(int i=1;i<=6;++i) b[i]=a[i];
std::sort(b+1,b+7);
for(int i=1;i<=6;++i){
int x=std::lower_bound(b+1,b+7,a[i])-b;
c[i]=x;
}
for(int i=1;i<=6;++i) d[i]=i;int cnt=0;
do{
++cnt;
bool flag=1;
for(int i=1;i<=6;++i)
if(d[i]!=c[i]){flag=0;break;}
if(flag) return cnt;
}while(std::next_permutation(d+1,d+7));
}
int main(){
char type[10];
read(type);
if(type[0]=='t'){
int T;read(T);while(T--){
read(n);
for(int i=1;i<=n;++i) read(a[i]);
int p=1;
for(int i=2;i<=n;++i)
if(a[i]>a[p]) p=i;
swap(a[13],a[p]);
int sum=0;
for(int i=1;i<=n;++i) sum^=a[i];
for(int i=1;i<=6;++i) d[i]=i;
while(--sum) std::next_permutation(d+1,d+7);
work(a),work(a+6),work(a+13);
for(int i=1;i<=n;++i) print(a[i]),print(' ');print('\n');
}
}
else{
int T;read(T);while(T--){
read(m);int sum=0;
for(int i=1;i<=m;++i) read(a[i]),sum^=a[i];
int r1=calc(a),r2=calc(a+6);
if(r1==r2){
for(int i=1;i<=m;++i) print(a[i]),print(' ');
if(r1!=sum) print(sum^r1);
print('\n');
continue;
}
r1=calc(a),r2=calc(a+12);
if(r1==r2){
for(int i=1;i<=m;++i) print(a[i]),print(' ');
if(r1!=sum) print(sum^r1);
print('\n');
continue;
}
r1=calc(a+5),r2=calc(a+12);
if(r1==r2){
for(int i=1;i<=m;++i) print(a[i]),print(' ');
if(r1!=sum) print(sum^r1);
print('\n');
continue;
}
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 4ms
memory: 3332kb
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:
87 32 99 97 388 459 271 98 325 296 330 403 467 267 58 378 333 405 426 374 120 451 125 150 481 136 26 281 68 192 444 118 495 61 339 86 292 494 100 32
input:
recover 2 19 87 32 99 97 388 459 271 98 325 296 330 403 467 267 58 378 333 405 426 19 120 451 125 150 136 26 281 68 192 444 118 495 61 339 86 292 494 100 32
output:
87 32 99 97 388 459 271 98 325 296 330 403 467 267 58 378 333 405 426 374 120 451 125 150 136 26 281 68 192 444 118 495 61 339 86 292 494 100 32 384
result:
wrong answer incorrect answer. (test case 2)