結果

問題 No.2307 [Cherry 5 th Tune *] Cool 46
ユーザー tailstails
提出日時 2023-05-24 20:57:54
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 23 ms / 2,000 ms
コード長 1,996 bytes
コンパイル時間 597 ms
コンパイル使用メモリ 35,224 KB
実行使用メモリ 12,416 KB
最終ジャッジ日時 2023-08-25 13:18:33
合計ジャッジ時間 26,552 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,620 KB
testcase_01 AC 1 ms
5,632 KB
testcase_02 AC 13 ms
8,552 KB
testcase_03 AC 14 ms
8,468 KB
testcase_04 AC 14 ms
9,348 KB
testcase_05 AC 11 ms
9,372 KB
testcase_06 AC 13 ms
9,476 KB
testcase_07 AC 11 ms
9,000 KB
testcase_08 AC 13 ms
9,516 KB
testcase_09 AC 14 ms
9,520 KB
testcase_10 AC 12 ms
9,212 KB
testcase_11 AC 17 ms
9,288 KB
testcase_12 AC 12 ms
9,164 KB
testcase_13 AC 19 ms
11,264 KB
testcase_14 AC 16 ms
8,948 KB
testcase_15 AC 12 ms
9,048 KB
testcase_16 AC 17 ms
12,156 KB
testcase_17 AC 13 ms
9,640 KB
testcase_18 AC 20 ms
11,572 KB
testcase_19 AC 16 ms
12,340 KB
testcase_20 AC 18 ms
12,084 KB
testcase_21 AC 19 ms
11,280 KB
testcase_22 AC 19 ms
12,124 KB
testcase_23 AC 20 ms
11,276 KB
testcase_24 AC 19 ms
12,280 KB
testcase_25 AC 19 ms
12,160 KB
testcase_26 AC 19 ms
12,116 KB
testcase_27 AC 22 ms
11,680 KB
testcase_28 AC 18 ms
12,204 KB
testcase_29 AC 20 ms
11,228 KB
testcase_30 AC 16 ms
12,284 KB
testcase_31 AC 18 ms
12,092 KB
testcase_32 AC 19 ms
12,076 KB
testcase_33 AC 23 ms
11,744 KB
testcase_34 AC 21 ms
11,844 KB
testcase_35 AC 18 ms
12,356 KB
testcase_36 AC 20 ms
11,420 KB
testcase_37 AC 20 ms
12,120 KB
testcase_38 AC 13 ms
8,316 KB
testcase_39 AC 18 ms
11,460 KB
testcase_40 AC 18 ms
11,024 KB
testcase_41 AC 13 ms
12,028 KB
testcase_42 AC 14 ms
12,416 KB
testcase_43 AC 16 ms
11,848 KB
testcase_44 AC 20 ms
12,024 KB
testcase_45 AC 18 ms
10,652 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:66:19: warning: multi-character character constant [-Wmultichar]
    *(unsigned*)wp='\noN';
                   ^~~~~~
main.c:73:14: warning: multi-character character constant [-Wmultichar]
    *(int*)wp='\nseY';
              ^~~~~~~
main.c:79:14: warning: multi-character character constant [-Wmultichar]
      wt_red(h);
              ^
main.c:84:13: warning: multi-character character constant [-Wmultichar]
     wt_red(h);
             ^
main.c:85:14: warning: multi-character character constant [-Wmultichar]
     wt_blue(h);
              ^
main.c:89:14: warning: multi-character character constant [-Wmultichar]
     wt_blue(h);
              ^
main.c:95:15: warning: multi-character character constant [-Wmultichar]
      wt_blue(h);
               ^
main.c:96:14: warning: multi-character character constant [-Wmultichar]
      wt_red(h);
              ^
main.c:101:14: warning: multi-character character constant [-Wmultichar]
      wt_red(h);
              ^
main.c:102:15: warning: multi-character character constant [-Wmultichar]
      wt_blue(h);
               ^
main.c:107:2: warning: implicit declaration of function ‘write’ [-Wimplicit-function-declaration]
  write(1,wbuf,wp-wbuf);
  ^~~~~
main.c:108:2: warning: implicit declaration of function ‘_exit’ [-Wimplicit-function-declaration]
  _exit(0);
  ^~~~~
main.c:108:2: warning: incompatible implicit declaration of built-in function ‘_exit’

ソースコード

diff #

#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")

#define rd_init() char*rp=({char*mmap();mmap(0l,1l<<25,1,2,0,0ll);})
#define rd_skip() while(*rp++>=48)
#define rd() ({long _v=0,_c;while(_c=*rp++-48,_c>=0)_v=_v*10+_c;_v;})
#define WTHI(v) {ulong _z=v,_n=0,_d=0;while(++_n,_d=_d<<8|0x30|_z%10,_z/=10);*(ulong*)wp=_d;wp+=_n;}
#define WTLO(v) {ulong _z=v,_n=8,_d=0;while(_d=_d<<8|0x30|_z%10,_z/=10,--_n);*(ulong*)wp=_d;wp+=8;}
#define wt(v) if(v>=100000000){WTHI(v/100000000);WTLO(v);}else{WTHI(v);}
#define wt_red(h) ({*(unsigned*)wp=' deR';wp+=4;wt(hash[h]);*wp++='\n';})
#define wt_blue(h) ({*(unsigned*)wp='eulB';wp+=4;;*wp++=' ';wt(hash[h]);*wp++='\n';})
#define rep(v,e) for(typeof(e) v=0;v<e;++v)

#define HASH_BITS 19
#define HASH_MASK ((1<<HASH_BITS)-1)
unsigned hash[1<<HASH_BITS];

int hash_add(unsigned x){
	int h=x&HASH_MASK;
	while(1){
		if(hash[h]==0){
			hash[h]=x;
			return h;
		}
		if(hash[h]==x){
			return h;
		}
		h=h+1&HASH_MASK;
	}
}

typedef unsigned long ulong;
char wbuf[1<<25];

char u[1<<HASH_BITS];
int as[1<<18],an;
int bs[1<<18],bn;
int cs[1<<18],cn;

int main(){
	rd_init();
	rd_skip();
	char*wp=wbuf;
	while(*rp){
		an=0;
		bn=0;
		cn=0;
		int n=rd(),m=rd();
		if(!n)++rp;
		rep(j,n){
			int h=hash_add(rd());
			u[h]=1;
			as[an++]=h;
		}
		if(!m)++rp;
		rep(j,m){
			int h=hash_add(rd());
			if(u[h]){
				u[h]=0;
				cs[cn++]=h;
			}else{
				bs[bn++]=h;
			}
		}
		if(cn==0&&an&&bn){
			*(unsigned*)wp='\noN';
			wp+=3;
			while(an){
				int h=as[--an];
				u[h]=0;
			}
		}else{
			*(int*)wp='\nseY';
			wp+=4;
			while(an){
				int h=as[--an];
				if(u[h]){
					u[h]=0;
					wt_red(h);
				}
			}
			if(cn){
				int h=cs[--cn];
				wt_red(h);
				wt_blue(h);
			}
			while(bn){
				int h=bs[--bn];
				wt_blue(h);
			}
			while(1){
				if(!cn)break;
				{
					int h=cs[--cn];
					wt_blue(h);
					wt_red(h);
				}
				if(!cn)break;
				{
					int h=cs[--cn];
					wt_red(h);
					wt_blue(h);
				}
			}
		}
	}
	write(1,wbuf,wp-wbuf);
	_exit(0);
}
0