1 条题解

  • 0
    @ 2026-11-2 12:34:49

    稳定原子(Stable Atom) 题解

    思路分析

    按题目要求使用对应数据结构与算法模拟/递推求解,注意数据范围边界与时间复杂度。

    参考代码

    #include <algorithm>
    #include <iostream>
    using namespace std;
    
    int main() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        int T;
        if (!(cin >> T)) return 0;
        while (T--) {
            int n;
            cin >> n;
            if (n % 2 == 1) {
                cout << "No\n";
            } else {
                cout << "Yes\n";
                for (int i = 0; i < n; ++i) {
                    for (int j = 0; j < n; ++j) {
                        int ring = min({i, j, n - 1 - i, n - 1 - j});
                        int val = (ring % 2 == 0) ? 1 : 0;
                        cout << val << (j + 1 == n ? "\n" : " ");
                    }
                }
            }
        }
        return 0;
    }
    
    • 1

    信息

    ID
    8604
    时间
    1000ms
    内存
    512MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者