結果
| 問題 | 
                            No.307 最近色塗る問題多くない?
                             | 
                    
| コンテスト | |
| ユーザー | 
                             tails
                         | 
                    
| 提出日時 | 2020-11-06 18:54:54 | 
| 言語 | C  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 6 ms / 4,000 ms | 
| コード長 | 1,491 bytes | 
| コンパイル時間 | 470 ms | 
| コンパイル使用メモリ | 33,792 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-07-22 11:50:05 | 
| 合計ジャッジ時間 | 2,305 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 36 | 
コンパイルメッセージ
main.c:45:1: warning: return type defaults to 'int' [-Wimplicit-int]
   45 | main(){
      | ^~~~
main.c: In function 'main':
main.c:87:9: warning: implicit declaration of function 'write' [-Wimplicit-function-declaration]
   87 |         write(1,wbuf,(char*)wp-wbuf);
      |         ^~~~~
main.c:88:9: warning: implicit declaration of function '_exit'; did you mean '_Exit'? [-Wimplicit-function-declaration]
   88 |         _exit(0);
      |         ^~~~~
      |         _Exit
            
            ソースコード
#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);
}
            
            
            
        
            
tails