結果

問題 No.2307 [Cherry 5 th Tune *] Cool 46
ユーザー tailstails
提出日時 2023-05-24 20:55:07
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 1,989 bytes
コンパイル時間 865 ms
コンパイル使用メモリ 35,144 KB
実行使用メモリ 11,964 KB
最終ジャッジ日時 2023-08-25 13:16:52
合計ジャッジ時間 28,529 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,560 KB
testcase_01 AC 1 ms
5,664 KB
testcase_02 AC 9 ms
8,912 KB
testcase_03 AC 11 ms
8,904 KB
testcase_04 AC 10 ms
8,796 KB
testcase_05 AC 9 ms
8,804 KB
testcase_06 AC 11 ms
8,888 KB
testcase_07 AC 9 ms
8,356 KB
testcase_08 AC 10 ms
8,928 KB
testcase_09 AC 11 ms
8,900 KB
testcase_10 AC 10 ms
8,668 KB
testcase_11 AC 12 ms
9,476 KB
testcase_12 AC 10 ms
8,548 KB
testcase_13 AC 14 ms
11,556 KB
testcase_14 AC 11 ms
9,020 KB
testcase_15 AC 10 ms
8,556 KB
testcase_16 AC 12 ms
11,572 KB
testcase_17 AC 11 ms
8,972 KB
testcase_18 AC 16 ms
11,552 KB
testcase_19 AC 12 ms
11,552 KB
testcase_20 AC 15 ms
11,504 KB
testcase_21 AC 14 ms
11,688 KB
testcase_22 AC 15 ms
11,508 KB
testcase_23 AC 14 ms
11,620 KB
testcase_24 AC 14 ms
11,612 KB
testcase_25 AC 14 ms
11,628 KB
testcase_26 AC 14 ms
11,564 KB
testcase_27 AC 15 ms
11,488 KB
testcase_28 AC 14 ms
11,492 KB
testcase_29 AC 14 ms
11,588 KB
testcase_30 AC 12 ms
11,488 KB
testcase_31 AC 15 ms
11,608 KB
testcase_32 AC 15 ms
11,560 KB
testcase_33 AC 15 ms
11,568 KB
testcase_34 AC 14 ms
11,556 KB
testcase_35 AC 12 ms
11,600 KB
testcase_36 AC 14 ms
11,512 KB
testcase_37 AC 14 ms
11,588 KB
testcase_38 AC 8 ms
8,840 KB
testcase_39 AC 12 ms
11,964 KB
testcase_40 AC 15 ms
11,496 KB
testcase_41 AC 10 ms
11,548 KB
testcase_42 AC 10 ms
11,592 KB
testcase_43 AC 11 ms
11,592 KB
testcase_44 AC 14 ms
11,564 KB
testcase_45 AC 14 ms
11,496 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 18
#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<<18];
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