結果
問題 |
No.839 Keep Distance and Nobody Explodes
|
ユーザー |
|
提出日時 | 2019-06-14 22:24:57 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 770 bytes |
コンパイル時間 | 1,680 ms |
コンパイル使用メモリ | 171,452 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-14 06:44:22 |
合計ジャッジ時間 | 3,130 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 1 WA * 29 |
ソースコード
#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 dy[] = {0, 0, 1, -1}; int dx[] = {1, -1, 0, 0}; int y[] = {0, n - 1, 0, n - 1}; int x[] = {0, n - 1, n - 1, 0}; for (int i = 0; i < n * n; i++) { int j = i % 4; ans[y[j]][x[j]] = i; int ny = y[j] + dy[j]; int nx = x[j] + dx[j]; if (ans[ny][nx] != -1) { int ty = dy[j]; int tx = dx[j]; dy[j] = tx; dx[j] = -ty; } y[j] += dy[j]; x[j] += dx[j]; } rep(i, n) { rep(j, n) { cout << ans[i][j]+1 << ' '; } cout << '\n'; } }