結果

問題 No.1916 Making Palindrome on Gird
ユーザー tailstails
提出日時 2022-04-29 23:07:43
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 17 ms / 3,000 ms
コード長 1,376 bytes
コンパイル時間 236 ms
コンパイル使用メモリ 32,064 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-11 14:36:29
合計ジャッジ時間 1,844 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 3 ms
4,376 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 AC 3 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 6 ms
4,380 KB
testcase_10 AC 0 ms
4,500 KB
testcase_11 AC 3 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 10 ms
4,380 KB
testcase_14 AC 9 ms
4,380 KB
testcase_15 AC 11 ms
4,380 KB
testcase_16 AC 10 ms
4,380 KB
testcase_17 AC 15 ms
4,376 KB
testcase_18 AC 16 ms
4,380 KB
testcase_19 AC 16 ms
4,384 KB
testcase_20 AC 16 ms
4,380 KB
testcase_21 AC 17 ms
4,376 KB
testcase_22 AC 16 ms
4,380 KB
testcase_23 AC 13 ms
4,376 KB
testcase_24 AC 13 ms
4,380 KB
testcase_25 AC 14 ms
4,376 KB
testcase_26 AC 14 ms
4,376 KB
testcase_27 AC 14 ms
4,380 KB
testcase_28 AC 17 ms
4,376 KB
testcase_29 AC 17 ms
4,376 KB
testcase_30 AC 17 ms
4,376 KB
testcase_31 AC 17 ms
4,380 KB
testcase_32 AC 17 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: 関数 ‘main’ 内:
main.c:72:9: 警告: 関数 ‘write’ の暗黙的な宣言です [-Wimplicit-function-declaration]
   72 |         write(1,wp,wbuf+sizeof wbuf-wp);
      |         ^~~~~
main.c:73:9: 警告: implicit declaration of function ‘_exit’; did you mean ‘_Exit’? [-Wimplicit-function-declaration]
   73 |         _exit(0);
      |         ^~~~~
      |         _Exit

ソースコード

diff #

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

#define rd() ({long _v=0,_c;while(_c=*rp++-48,_c>=0)_v=_v*10+_c;_v;})
#define wt(v) {ulong _z=v;do*--wp=_z%10+48;while(_z/=10);}
#define rep(v,e) for(long v=0;v<e;++v)
#define rep3(v,s,e) for(long v=s;v<e;++v)
#define rrep(v,e) for(long v=e;v--;)

typedef unsigned long ulong;

#define MD 1000000007

unsigned src[402][402],dst[402][402];
char*s;
long h,w;

char at(int y,int x){
	return s[x+y*(w+1)];
}

int main(){
	{
		char*mmap();
		char*rp=mmap(0l,1l<<25,1,2,0,0ll);
		h=rd();
		w=rd();
		s=rp;
	}
	if((h+w&1)==0){
		long st=h<=w?0:h-w>>1;
		long ed=st+(h<=w?h:w);
		rep3(y,st,ed){
			src[y+1][y+1]=1;
		}
	}
	else{
		long st=h<=w?0:h-w>>1;
		long ed=st+(h<=w?h:w);
		rep3(y,st,ed){
			if(at(y,(w+h>>1)-y-1)==at(y,(w+h>>1)-y)){
				src[y+1][y+1]=1;
			}
			if(at(y,(w+h>>1)-y-1)==at(y+1,(w+h>>1)-y-1)){
				src[y+1][y+2]=1;
			}
		}
	}
	rrep(i,(w+h>>1)-1){
		long l=i+1;
		l=l<=h?l:h;
		l=l<=w?l:w;
		long st=i<w?0:i-1-w;
		long ed=st+l;
		rep3(y1,st,ed){
			rep3(y2,h-ed,h-st){
				if(at(y1,i-y1)==at(y2,h+w-2-i-y2)){
					dst[y1+1][y2+1]=(0ul+src[y1+1][y2+1]+src[y1+1][y2+0]+src[y1+2][y2+1]+src[y1+2][y2+0])%MD;
				}
			}
		}
		rep(j,402){
			rep(k,402){
				src[j][k]=dst[j][k];
				dst[j][k]=0;
			}
		}
	}

	char wbuf[64],*wp=wbuf+sizeof wbuf;
	wt(src[1][h]);
	write(1,wp,wbuf+sizeof wbuf-wp);
	_exit(0);
}
0