結果

問題 No.307 最近色塗る問題多くない?
ユーザー tailstails
提出日時 2020-11-06 18:54:54
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 8 ms / 4,000 ms
コード長 1,491 bytes
コンパイル時間 475 ms
コンパイル使用メモリ 32,648 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-29 17:50:39
合計ジャッジ時間 2,845 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,384 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 0 ms
4,376 KB
testcase_06 AC 0 ms
4,376 KB
testcase_07 AC 1 ms
4,384 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 0 ms
4,376 KB
testcase_14 AC 0 ms
4,380 KB
testcase_15 AC 0 ms
4,380 KB
testcase_16 AC 0 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 7 ms
4,380 KB
testcase_24 AC 3 ms
4,380 KB
testcase_25 AC 4 ms
4,376 KB
testcase_26 AC 7 ms
4,380 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 0 ms
4,380 KB
testcase_30 AC 8 ms
4,376 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 1 ms
4,376 KB
testcase_34 AC 2 ms
4,504 KB
testcase_35 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:45:1: 警告: 戻り値の型をデフォルトの ‘int’ にします [-Wimplicit-int]
   45 | main(){
      | ^~~~
main.c: 関数 ‘main’ 内:
main.c:87:9: 警告: 関数 ‘write’ の暗黙的な宣言です [-Wimplicit-function-declaration]
   87 |         write(1,wbuf,(char*)wp-wbuf);
      |         ^~~~~
main.c:88:9: 警告: implicit declaration of function ‘_exit’; did you mean ‘_Exit’? [-Wimplicit-function-declaration]
   88 |         _exit(0);
      |         ^~~~~
      |         _Exit

ソースコード

diff #

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

char*mmap();
#define RD(v) int v=0;{int _c;while(_c=*rp++-48,_c>=0)v=v*10+_c;}

char wbuf[2*200*200];

typedef unsigned long mt;

#define YDUP(x) ((x)*0x0101010101010101ul)

int w,h;
mt board[26][26];
mt mask_y;
mt mask_x;

mt mode;
int count;

void fill(int y,int x,mt m){
	mt b=board[y][x]^mode;
	if(y==h>>3){
		b&=mask_y;
	}
	if(x==w>>3){
		b&=mask_x;
	}
	m&=b;
	if(!m) return;
	mt p;
	do{
		p=m;
		m|=m<<8|m>>8|(m<<1&YDUP(0xfe))|(m>>1&YDUP(0x7f));
		m&=b;
	}while(p!=m);
	count+=__builtin_popcountl(m);
	board[y][x]^=m;
	if(y>0) fill(y-1,x,m<<56);
	fill(y+1,x,m>>56);
	if(x>0) fill(y,x-1,m<<7&YDUP(0x80));
	fill(y,x+1,m>>7&YDUP(1));
}

main(){
	char*rp=mmap(0l,0l|2*200*200+10*50000+100,1,2,0,0ll);
	{ RD(t); h=t; }
	{ RD(t); w=t; }
	int hw=h*w;
	mask_y=~(~0ul<<((h&7)<<3));
	mask_x=YDUP(~(~0ul<<(w&7)));
	for(int y=0;y<h;++y){
		for(int x=0;x<w;++x){
			board[y>>3][x>>3]|=(*rp&1ul)<<((y&7)<<3|(x&7));
			rp+=2;
		}
	}
	RD(q);
	while(q--){
		RD(y); --y;
		RD(x); --x;
		count=0;
		mode=-(*rp&1ul);
		rp+=2;
		fill(y>>3,x>>3,1ul<<((y&7)<<3|(x&7)));
		if(count==hw) break;
	}

	short*wp=(short*)wbuf;
	if(*rp){
		while(*++rp);
		int z=rp[-2]&1|0x2030;
		for(int y=0;y<h;++y){
			for(int x=0;x<w;++x){
				*wp++=z;
			}
			wp[-1]^=0x2a00;
		}
	}else{
		for(int y=0;y<h;++y){
			for(int x=0;x<w;++x){
				*wp++=board[y>>3][x>>3]>>((y&7)<<3|(x&7))&1|0x2030;
			}
			wp[-1]^=0x2a00;
		}
	}
	write(1,wbuf,(char*)wp-wbuf);
	_exit(0);
}
0