結果
| 問題 | 
                            No.839 Keep Distance and Nobody Explodes
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2020-08-05 13:55:27 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 10 ms / 2,000 ms | 
| コード長 | 833 bytes | 
| コンパイル時間 | 837 ms | 
| コンパイル使用メモリ | 75,384 KB | 
| 最終ジャッジ日時 | 2025-01-12 14:53:33 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 30 | 
ソースコード
#include <iostream>
#include <vector>
template <class T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }
void solve() {
    int n;
    std::cin >> n;
    auto ans = vec(n, vec(n, 0));
    int m = n / 2;
    int id = 1;
    for (int x = 0; x < m; ++x) {
        for (int y = 0; y < m; ++y) {
            ans[x][y] = id++;
            ans[x + m][y + m] = id++;
        }
    }
    for (int x = 0; x < m; ++x) {
        for (int y = 0; y < m; ++y) {
            ans[x][(n - 1) - y] = id++;
            ans[x + m][(n - 1) - (y + m)] = id++;
        }
    }
    for (const auto& v : ans) {
        for (auto x : v) {
            std::cout << x << " ";
        }
        std::cout << "\n";
    }
}
int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    solve();
    return 0;
}