結果

問題 No.1028 闇討ち
コンテスト
ユーザー testestest
提出日時 2021-06-01 09:52:03
言語 C90(gcc12)
(gcc 12.4.0)
コンパイル:
gcc-12 -O2 -std=c90 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 371 ms / 2,000 ms
コード長 554 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 153 ms
コンパイル使用メモリ 35,464 KB
実行使用メモリ 9,580 KB
最終ジャッジ日時 2026-03-08 16:27:05
合計ジャッジ時間 4,459 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 20
権限があれば一括ダウンロードができます
コンパイルメッセージ
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:9:1: warning: data definition has no type or storage class
    9 | i,j,k,t;
      | ^
main.c:10:1: warning: data definition has no type or storage class
   10 | ans,temp,temptemp;
      | ^~~
main.c: In function ‘main’:
main.c:12:9: warning: incompatible implicit declaration of built-in function ‘scanf’ [-Wbuiltin-declaration-mismatch]
   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:27:9: warning: incompatible implicit declaration of built-in function ‘printf’ [-Wbuiltin-declaration-mismatch]
   27 |         printf("%d",ans);
      |         ^~~~~~
main.c:27:9: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’

ソースコード

diff #
raw source code

#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