結果

問題 No.325 マンハッタン距離2
コンテスト
ユーザー 👑 tails
提出日時 2015-12-18 00:42:21
言語 C90
(gcc 12.4.0)
コンパイル:
gcc-12 -O2 -std=c90 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 1 ms / 1,000 ms
コード長 370 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 116 ms
コンパイル使用メモリ 29,732 KB
最終ジャッジ日時 2026-02-23 20:09:24
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:14:9: warning: incompatible implicit declaration of built-in function ‘scanf’ [-Wbuiltin-declaration-mismatch]
   14 |         scanf("%d%d%d%d%d",&u,&v,&x,&y,&d);
      |         ^~~~~
main.c:1:1: note: include ‘<stdio.h>’ or provide a declaration of ‘scanf’
  +++ |+#include <stdio.h>
    1 | typedef long long l;
main.c:19:12: warning: incompatible implicit declaration of built-in function ‘printf’ [-Wbuiltin-declaration-mismatch]
   19 |         s=!printf("%llu",s);
      |            ^~~~~~
main.c:19:12: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’

ソースコード

diff #
raw source code

typedef long long l;
l s;
l g(x){return x>0?(l)x*-~x/2:0;}
f(u,v,x,y,d,t){
	if(u>x)t=u,u=x,x=t;
	if(v>y)t=v,v=y,y=t;
	if((x|y|d)>=0){
		if(u>0)x-=u,d-=u;
		if(v>0)y-=v,d-=v;
		s+=d>x+y?~(l)x*~y:g(d+1)-g(d-x)-g(d-y);
	}
}
main(u,v,x,y,d){
	scanf("%d%d%d%d%d",&u,&v,&x,&y,&d);
	f(u,v,x,y,d);
	f(~u,v,~x,y,--d);
	f(u,~v,x,~y,d);
	f(~u,~v,~x,~y,--d);
	s=!printf("%llu",s);
}
0