結果

問題 No.1028 闇討ち
ユーザー testestesttestestest
提出日時 2021-06-01 09:52:03
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 365 ms / 2,000 ms
コード長 554 bytes
コンパイル時間 497 ms
コンパイル使用メモリ 34,048 KB
実行使用メモリ 9,728 KB
最終ジャッジ日時 2024-11-09 00:10:01
合計ジャッジ時間 4,683 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 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 1 ms
5,248 KB
testcase_07 AC 1 ms
5,248 KB
testcase_08 AC 1 ms
5,248 KB
testcase_09 AC 8 ms
5,248 KB
testcase_10 AC 12 ms
5,248 KB
testcase_11 AC 56 ms
5,504 KB
testcase_12 AC 334 ms
9,472 KB
testcase_13 AC 330 ms
9,344 KB
testcase_14 AC 153 ms
7,424 KB
testcase_15 AC 37 ms
5,248 KB
testcase_16 AC 364 ms
9,600 KB
testcase_17 AC 365 ms
9,600 KB
testcase_18 AC 362 ms
9,600 KB
testcase_19 AC 360 ms
9,600 KB
testcase_20 AC 363 ms
9,728 KB
testcase_21 AC 362 ms
9,600 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:5:25: warning: no semicolon at end of struct or union
    5 | typedef struct p{int x,y}pair;
      |                         ^
main.c:7:1: warning: data definition has no type or storage class
    7 | cnt[1000];
      | ^~~
main.c:7:1: warning: type defaults to 'int' in declaration of 'cnt' [-Wimplicit-int]
main.c:9:1: warning: data definition has no type or storage class
    9 | i,j,k,t;
      | ^
main.c:9:1: warning: type defaults to 'int' in declaration of 'i' [-Wimplicit-int]
main.c:9:3: warning: type defaults to 'int' in declaration of 'j' [-Wimplicit-int]
    9 | i,j,k,t;
      |   ^
main.c:9:5: warning: type defaults to 'int' in declaration of 'k' [-Wimplicit-int]
    9 | i,j,k,t;
      |     ^
main.c:9:7: warning: type defaults to 'int' in declaration of 't' [-Wimplicit-int]
    9 | i,j,k,t;
      |       ^
main.c:10:1: warning: data definition has no type or storage class
   10 | ans,temp,temptemp;
      | ^~~
main.c:10:1: warning: type defaults to 'int' in declaration of 'ans' [-Wimplicit-int]
main.c:10:5: warning: type defaults to 'int' in declaration of 'temp' [-Wimplicit-int]
   10 | ans,temp,temptemp;
      |     ^~~~
main.c:10:10: warning: type defaults to 'int' in declaration of 'temptemp' [-Wimplicit-int]
   10 | ans,temp,temptemp;
      |          ^~~~~~~~
main.c:11:1: warning: return type defaults to 'int' [-Wimplicit-int]
   11 | main(n){
      | ^~~~
main.c: In function 'main':
main.c:11:1: warning: type of 'n' defaults to 'int' [-Wimplicit-int]
main.c:12:9: warning: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
   12 |         scanf("%d",&n);
      |         ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | #pragma GCC target("avx2")
main.c:12:9: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
   12 |         scanf("%d",&n);
      |         ^~~~~
main.c:12:9: note: include '<stdio.h>' or p

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#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