結果

問題 No.1384 Bishop and Rook
ユーザー tailstails
提出日時 2021-05-20 15:29:58
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 18 ms / 2,000 ms
コード長 1,608 bytes
コンパイル時間 280 ms
コンパイル使用メモリ 37,504 KB
実行使用メモリ 9,088 KB
最終ジャッジ日時 2024-04-18 14:04:20
合計ジャッジ時間 4,821 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 10 ms
5,504 KB
testcase_02 AC 4 ms
5,376 KB
testcase_03 AC 3 ms
5,376 KB
testcase_04 AC 3 ms
5,376 KB
testcase_05 AC 7 ms
5,376 KB
testcase_06 AC 8 ms
5,376 KB
testcase_07 AC 12 ms
5,888 KB
testcase_08 AC 9 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 7 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 15 ms
7,552 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 18 ms
8,832 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 12 ms
7,424 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 1 ms
5,376 KB
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 1 ms
5,376 KB
testcase_26 AC 1 ms
5,376 KB
testcase_27 AC 1 ms
5,376 KB
testcase_28 AC 1 ms
5,376 KB
testcase_29 AC 1 ms
5,376 KB
testcase_30 AC 1 ms
5,376 KB
testcase_31 AC 1 ms
5,376 KB
testcase_32 AC 1 ms
5,376 KB
testcase_33 AC 1 ms
5,376 KB
testcase_34 AC 1 ms
5,376 KB
testcase_35 AC 1 ms
5,376 KB
testcase_36 AC 1 ms
5,376 KB
testcase_37 AC 1 ms
5,376 KB
testcase_38 AC 1 ms
5,376 KB
testcase_39 AC 1 ms
5,376 KB
testcase_40 AC 1 ms
5,376 KB
testcase_41 AC 3 ms
5,376 KB
testcase_42 AC 2 ms
5,376 KB
testcase_43 AC 3 ms
5,376 KB
testcase_44 AC 3 ms
5,376 KB
testcase_45 AC 2 ms
5,376 KB
testcase_46 AC 2 ms
5,376 KB
testcase_47 AC 2 ms
5,376 KB
testcase_48 AC 3 ms
5,376 KB
testcase_49 AC 1 ms
5,376 KB
testcase_50 AC 1 ms
5,376 KB
testcase_51 AC 1 ms
5,376 KB
testcase_52 AC 18 ms
9,088 KB
testcase_53 AC 7 ms
5,376 KB
testcase_54 AC 1 ms
6,944 KB
testcase_55 AC 1 ms
6,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:74:1: warning: return type defaults to 'int' [-Wimplicit-int]
   74 | main(){
      | ^~~~
main.c: In function 'main':
main.c:79:9: warning: implicit declaration of function 'write' [-Wimplicit-function-declaration]
   79 |         write(1,gwp,wbuf+sizeof wbuf-gwp);
      |         ^~~~~
main.c:80:9: warning: implicit declaration of function '_exit'; did you mean '_Exit'? [-Wimplicit-function-declaration]
   80 |         _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[1<<28];
#define wt(v) {long _z=v;do*--wp=_z%10+48;while(_z/=10);}

char*grp,*gwp;

void solve(){
	if(*grp){
		char*rp=grp;
		rd(n);
		rd(m);
		grp=rp;

		solve();

		char*wp=gwp;
		if(n==1&&m==1){
			*--wp='\n';
			*--wp='1';
			*--wp=' ';
			*--wp='1';
			*--wp='\n';
			*--wp='0';
			goto end;
		}
		if((n|m)&1){
			*--wp='\n';
			*--wp='1';
			*--wp='-';
			goto end;
		}
		for(int y=0;y<n;y+=2){
			if(!(y&2)){
				for(int x=0;x<m-2;x+=2){
					*--wp='\n'; wt(x+1); *--wp=' '; wt(y+1);
					*--wp='\n'; wt(x+2); *--wp=' '; wt(y+2);
					*--wp='\n'; wt(x+1); *--wp=' '; wt(y+2);
					*--wp='\n'; wt(x+2); *--wp=' '; wt(y+1);
				}
				{
					*--wp='\n'; wt(m-1); *--wp=' '; wt(y+1);
					*--wp='\n'; wt(m-0); *--wp=' '; wt(y+2);
					*--wp='\n'; wt(m-0); *--wp=' '; wt(y+1);
					*--wp='\n'; wt(m-1); *--wp=' '; wt(y+2);
				}
			}else{
				{
					*--wp='\n'; wt(m-1); *--wp=' '; wt(y+1);
					*--wp='\n'; wt(m-0); *--wp=' '; wt(y+2);
					*--wp='\n'; wt(m-0); *--wp=' '; wt(y+1);
					*--wp='\n'; wt(m-1); *--wp=' '; wt(y+2);
				}
				for(int x=m-2;x-=2,x>=0;){
					*--wp='\n'; wt(x+2); *--wp=' '; wt(y+2);
					*--wp='\n'; wt(x+1); *--wp=' '; wt(y+1);
					*--wp='\n'; wt(x+2); *--wp=' '; wt(y+1);
					*--wp='\n'; wt(x+1); *--wp=' '; wt(y+2);
				}
			}
		}
		*--wp='\n';
		wt(m*n-1);

		end:;
		gwp=wp;
	}
}

main(){
	grp=mmap(0l,1l<<28,1,2,0,0ll);
	gwp=wbuf+sizeof wbuf;
	while(*grp++>=48);
	solve();
	write(1,gwp,wbuf+sizeof wbuf-gwp);
	_exit(0);
}
0