結果

問題 No.1028 闇討ち
ユーザー 👑 testestesttestestest
提出日時 2021-06-01 09:50:19
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1,633 ms / 2,000 ms
コード長 463 bytes
コンパイル時間 151 ms
コンパイル使用メモリ 30,336 KB
実行使用メモリ 9,600 KB
最終ジャッジ日時 2024-11-09 00:09:33
合計ジャッジ時間 15,831 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 1 ms
5,248 KB
testcase_03 AC 1 ms
5,248 KB
testcase_04 AC 1 ms
5,248 KB
testcase_05 AC 1 ms
5,248 KB
testcase_06 AC 2 ms
5,248 KB
testcase_07 AC 1 ms
5,248 KB
testcase_08 AC 1 ms
5,248 KB
testcase_09 AC 18 ms
5,248 KB
testcase_10 AC 28 ms
5,248 KB
testcase_11 AC 192 ms
5,376 KB
testcase_12 AC 1,486 ms
9,472 KB
testcase_13 AC 1,475 ms
9,344 KB
testcase_14 AC 617 ms
7,424 KB
testcase_15 AC 126 ms
5,248 KB
testcase_16 AC 1,625 ms
9,600 KB
testcase_17 AC 1,622 ms
9,472 KB
testcase_18 AC 1,632 ms
9,600 KB
testcase_19 AC 1,631 ms
9,600 KB
testcase_20 AC 1,629 ms
9,472 KB
testcase_21 AC 1,633 ms
9,472 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:2:25: warning: no semicolon at end of struct or union
    2 | typedef struct p{int x,y}pair;
      |                         ^
main.c:4:1: warning: data definition has no type or storage class
    4 | cnt[1000];
      | ^~~
main.c:4:1: warning: type defaults to 'int' in declaration of 'cnt' [-Wimplicit-int]
main.c:6:1: warning: data definition has no type or storage class
    6 | i,j,k,t;
      | ^
main.c:6:1: warning: type defaults to 'int' in declaration of 'i' [-Wimplicit-int]
main.c:6:3: warning: type defaults to 'int' in declaration of 'j' [-Wimplicit-int]
    6 | i,j,k,t;
      |   ^
main.c:6:5: warning: type defaults to 'int' in declaration of 'k' [-Wimplicit-int]
    6 | i,j,k,t;
      |     ^
main.c:6:7: warning: type defaults to 'int' in declaration of 't' [-Wimplicit-int]
    6 | i,j,k,t;
      |       ^
main.c:7:1: warning: data definition has no type or storage class
    7 | ans,temp,temptemp;
      | ^~~
main.c:7:1: warning: type defaults to 'int' in declaration of 'ans' [-Wimplicit-int]
main.c:7:5: warning: type defaults to 'int' in declaration of 'temp' [-Wimplicit-int]
    7 | ans,temp,temptemp;
      |     ^~~~
main.c:7:10: warning: type defaults to 'int' in declaration of 'temptemp' [-Wimplicit-int]
    7 | ans,temp,temptemp;
      |          ^~~~~~~~
main.c:8:1: warning: return type defaults to 'int' [-Wimplicit-int]
    8 | main(n){
      | ^~~~
main.c: In function 'main':
main.c:8:1: warning: type of 'n' defaults to 'int' [-Wimplicit-int]
main.c:9:9: warning: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
    9 |         scanf("%d",&n);
      |         ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | #define max(a,b,c)(a>b?a>c?a:c:b>c?b:c)
main.c:9:9: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
    9 |         scanf("%d",&n);
      |         ^~~~~
main.c:9:9: note: include '<stdio.h>' 

ソースコード

diff #

#define max(a,b,c)(a>b?a>c?a:c:b>c?b:c)
typedef struct p{int x,y}pair;
pair a[1000][1000];
cnt[1000];

i,j,k,t;
ans,temp,temptemp;
main(n){
	scanf("%d",&n);
	for(i=0;i<n;i++)for(j=0;j<n;j++){
		scanf("%d",&t);t--;
		pair x={i,j};
		a[t][cnt[t]++]=x;
	}
	for(t=0;t<n;t++){
		temp=1e9;
		for(i=0;i<n;i++){
			temptemp=0;
			for(k=0;k<n;k++)temptemp+=max(a[t][k].y,a[t][k].x-i,i-a[t][k].x);
			if(temptemp<temp)temp=temptemp;
		}
		ans+=temp;
	}
	printf("%d",ans);
}
0