結果

問題 No.1028 闇討ち
ユーザー risujirohrisujiroh
提出日時 2020-04-17 21:31:37
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,055 ms / 2,000 ms
コード長 687 bytes
コンパイル時間 2,236 ms
コンパイル使用メモリ 200,268 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2024-04-14 13:05:58
合計ジャッジ時間 12,396 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 13 ms
6,940 KB
testcase_10 AC 20 ms
6,944 KB
testcase_11 AC 125 ms
6,940 KB
testcase_12 AC 965 ms
10,624 KB
testcase_13 AC 949 ms
10,624 KB
testcase_14 AC 400 ms
7,424 KB
testcase_15 AC 82 ms
6,944 KB
testcase_16 AC 1,044 ms
11,136 KB
testcase_17 AC 1,044 ms
11,264 KB
testcase_18 AC 1,055 ms
11,136 KB
testcase_19 AC 1,052 ms
11,136 KB
testcase_20 AC 1,049 ms
11,008 KB
testcase_21 AC 1,052 ms
11,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector a(n, vector<int>(n));
  for (auto&& v : a) {
    for (auto&& e : v) {
      cin >> e;
      --e;
    }
  }
  vector d(n, vector<int>(n));
  for (int r = 0; r < n; ++r) {
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        d[r][a[i][j]] += max(abs(i - r), j);
      }
    }
  }
  int res = 0;
  for (int k = 0; k < n; ++k) {
    int mn = 1e9;
    for (int r = 0; r < n; ++r) {
      mn = min(mn, d[r][k]);
    }
    res += mn;
  }
  cout << res << '\n';
}
0