QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#22361#2351. Lost in TransferQyc_AK_NOI2022#0 4ms3576kbC++207.2kb2022-03-09 16:06:472023-01-17 09:33:49

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-01-17 09:33:49]
  • 评测
  • 测评结果:0
  • 用时:4ms
  • 内存:3576kb
  • [2022-03-09 16:06:47]
  • 提交

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=100+13;
int n,a[N],d[10],e[10];
inline void work(int *a){
	for(int i=1;i<=6;++i) e[d[i]]=i;
	int b[10],c[10];
	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[e[x]]=a[i];
	}
	for(int i=1;i<=6;++i) a[i]=c[i];
	std::reverse(a+1,a+7);
}
int m;
inline int calc(int *a){
	int b[10],c[10];
	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[6-i+1]=x;
	}
	for(int i=1;i<=6;++i) d[i]=i;int cnt=-1;
	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(){
#ifdef LOCAL
	freopen("d.in","r",stdin);
	freopen("d.out","w",stdout);
#endif
	char type[10];
	read(type);
	if(type[0]=='t'){
		int test=0;
		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[14],a[p]);
			p=1;
			for(int i=2;i<=n;++i)
				if(i!=7&&a[i]>a[p]) p=i;
			swap(a[7],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+7),work(a+14);
			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+7);
			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+13);
			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+6),r2=calc(a+13);
			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: 100
Accepted
time: 4ms
memory: 3576kb

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 459 99 333 32 97 467 330 403 296 325 87 271 98 405 426 374 378 58 267 
125 451 150 481 136 61 495 68 192 120 281 118 26 444 86 339 292 494 100 32 

input:

recover
2
19 388 459 99 333 32 97 467 330 403 296 325 87 271 98 405 426 374 378 58 
19 125 451 150 481 61 495 68 192 120 281 118 26 444 86 339 292 494 100 32 

output:

388 459 99 333 32 97 467 330 403 296 325 87 271 98 405 426 374 378 58 267
125 451 150 481 61 495 68 192 120 281 118 26 444 86 339 292 494 100 32 136

result:

ok all correct (2 test cases)

Test #2:

score: 100
Accepted
time: 4ms
memory: 3476kb

input:

transmit
1
20 158 220 174 224 137 134 339 175 147 122 480 26 151 266 474 144 451 301 105 188

output:

224 220 174 158 137 134 480 266 175 151 147 122 26 339 474 451 301 188 144 105 

input:

recover
1
19 224 220 174 158 137 134 480 266 175 151 147 122 26 339 474 451 301 188 144 

output:

224 220 174 158 137 134 480 266 175 151 147 122 26 339 474 451 301 188 144 105

result:

ok all correct (1 test case)

Test #3:

score: 100
Accepted
time: 2ms
memory: 3436kb

input:

transmit
1
100 170 478 377 395 397 329 488 424 11 337 249 156 489 244 386 400 81 195 264 272 491 24 280 422 365 382 354 91 23 148 469 196 287 191 368 436 132 84 43 126 451 28 94 61 34 301 104 309 127 116 44 82 21 312 222 294 186 112 210 161 261 131 484 219 430 271 310 184 67 149 119 291 125 267 449 ...

output:

377 478 170 395 397 329 491 249 489 11 337 424 156 488 264 400 81 272 386 195 244 24 280 422 365 382 354 91 23 148 469 196 287 191 368 436 132 84 43 126 451 28 94 61 34 301 104 309 127 116 44 82 21 312 222 294 186 112 210 161 261 131 484 219 430 271 310 184 67 149 119 291 125 267 449 74 383 252 256 ...

input:

recover
1
99 377 478 170 395 397 329 491 249 489 11 337 424 156 488 264 400 81 272 386 195 244 24 280 422 365 382 354 91 23 148 469 196 287 191 368 436 132 84 43 126 451 28 94 61 34 301 104 309 127 116 44 82 21 312 222 294 186 112 210 161 261 131 484 219 430 271 310 184 67 149 119 291 125 267 449 74...

output:

377 478 170 395 397 329 491 249 489 11 337 424 156 488 264 400 81 272 386 195 244 24 280 422 365 382 354 91 23 148 469 196 287 191 368 436 132 84 43 126 451 28 94 61 34 301 104 309 127 116 44 82 21 312 222 294 186 112 210 161 261 131 484 219 430 271 310 184 67 149 119 291 125 267 449 74 383 252 256 ...

result:

ok all correct (1 test case)

Test #4:

score: 100
Accepted
time: 4ms
memory: 3440kb

input:

transmit
9
20 130 404 101 44 439 315 251 150 63 463 202 322 48 139 15 276 212 332 238 46
30 470 31 62 452 226 135 150 419 30 380 494 32 386 179 253 451 106 384 116 197 80 133 474 151 293 104 54 350 334 433
40 197 419 332 235 451 154 411 319 78 10 474 125 377 93 336 385 256 188 395 66 449 363 94 223 ...

output:

439 315 44 101 404 130 463 322 150 48 63 202 139 251 332 238 15 46 276 212 
31 62 452 135 470 226 494 30 32 386 179 419 380 150 106 116 384 197 451 253 80 133 474 151 293 104 54 350 334 433 
197 419 235 154 451 332 479 78 377 125 10 474 319 411 188 385 256 66 395 336 449 363 94 223 171 313 430 444 2...

input:

recover
9
19 439 315 44 101 404 130 463 322 150 48 63 202 139 251 332 238 15 46 276 
29 31 62 452 135 470 226 494 30 32 386 179 419 380 150 116 384 197 451 253 80 133 474 151 293 104 54 350 334 433 
39 197 419 235 154 451 332 479 78 377 125 10 474 319 411 188 385 256 66 395 336 449 363 94 171 313 43...

output:

439 315 44 101 404 130 463 322 150 48 63 202 139 251 332 238 15 46 276 212
31 62 452 135 470 226 494 30 32 386 179 419 380 150 116 384 197 451 253 80 133 474 151 293 104 54 350 334 433 106
197 419 235 154 451 332 479 78 377 125 10 474 319 411 188 385 256 66 395 336 449 363 94 171 313 430 444 214 448...

result:

ok all correct (9 test cases)

Test #5:

score: 0
Wrong Answer

input:

transmit
81
100 345 473 156 472 449 361 478 451 332 324 120 264 105 37 287 102 369 417 331 458 284 55 25 115 279 489 257 468 463 200 174 431 408 492 411 227 140 303 89 35 12 371 169 139 485 480 20 373 220 211 330 138 228 466 432 44 166 80 443 24 92 21 160 376 351 190 214 173 132 322 163 340 7 282 40...

output:

472 449 473 345 361 156 498 332 324 451 120 264 105 478 417 369 458 287 331 102 284 55 25 115 279 489 257 468 463 200 174 431 408 492 411 227 140 303 89 35 12 371 169 139 485 480 20 373 220 211 330 138 228 466 432 44 166 80 443 24 92 21 160 376 351 190 214 173 132 322 163 340 7 282 409 37 114 207 34...

input:


output:


result:

wrong answer The sequence your program outputs on the first run is invalid. (test case 81)