結果

問題 No.839 Keep Distance and Nobody Explodes
ユーザー pekempeypekempey
提出日時 2019-06-14 22:31:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 758 bytes
コンパイル時間 1,695 ms
コンパイル使用メモリ 169,088 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-04-26 17:24:36
合計ジャッジ時間 5,364 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,752 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (int)(n) - 1; i >= 0; i--)
using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<vector<int>> ans(n, vector<int>(n, -1));
  int y = 0;
  int x = 0;
  ans[0][0] = 1;
  for (int i = 2; i <= n * n; i++) {
    tuple<int, int, int> t(-1, -1, -1);
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (ans[i][j] != -1) continue;
        int cost = (y - i) * (y - i) + (x - j) * (x - j);
        t = max(t, make_tuple(cost, i, j));
      }
    }
    y = get<1>(t);
    x = get<2>(t);
    ans[y][x] = i;
  }
  rep(i, n) {
    rep(j, n) {
      cout << ans[i][j] << ' ';
    }
    cout << '\n';
  }
}
0