結果

問題 No.2212 One XOR Matrix
ユーザー kztasakztasa
提出日時 2023-02-11 16:15:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 108 ms / 2,000 ms
コード長 3,146 bytes
コンパイル時間 4,064 ms
コンパイル使用メモリ 238,596 KB
実行使用メモリ 14,176 KB
最終ジャッジ日時 2023-09-22 12:57:23
合計ジャッジ時間 6,293 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 4 ms
4,376 KB
testcase_07 AC 9 ms
4,376 KB
testcase_08 AC 28 ms
6,200 KB
testcase_09 AC 108 ms
14,176 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h> 
#include <atcoder/all>

#define pub push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (ll i = m; i < (n); i++)
#define per(i, b) per2(i, 0, b)
#define per2(i, a, b) for (ll i = int(b) - 1; i >= int(a); i--)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
using ll = long long;
using Pll = pair<ll, ll>;


using namespace atcoder;
using mint = modint998244353;
using mint2 = modint1000000007;

constexpr long long INF = (1LL << 60);
constexpr double EPS = 1e-9;
constexpr double PI = 3.141592653589;


template <typename T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;  // aをbで更新
        return true;
    }
    return false;
}

template <typename T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;  // aをbで更新
        return true;
    }
    return false;
}

template <typename T>
T sq(T x) {
    return x * x;
}

std::string zfill(int n, const int width)
{
    std::stringstream ss;
    ss << std::setw(width) << std::setfill('0') << n;
    return ss.str();
}

bool isp(ll num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

template<typename T = int>
std::map<T, int> factorize(T n) {
    std::map<T, int> factor_map;
    for (T i = 2; i * i <= n; i++) {
        while (!(n % i)) {
            factor_map[i]++; n /= i;
        }
    }
    if (n > 1) factor_map[n]++;
    return factor_map;
}



int main() {
    ll N; cin >> N;
    if (N == 1) {
        cout << -1 << endl;
        return 0;
    }
    else {
        N--;
        vector<vector<vector<ll>>> ans(N);
        rep(i, N) {
            if (i == 0) {
                ans[i].pub({ 7,14,0,8 });
                ans[i].pub({ 4,12,2,11 });
                ans[i].pub({ 15,9,6,1 });
                ans[i].pub({ 13,10,5,3 });
            }
            else {
                ans[i] = ans[i - 1];
                ll t = 1 << (2 * (i + 1));
                rep(j, 1<<(i+1)) {
                    rep(k, 1<<(i + 1)) {
                        ans[i][j].pub(t);
                        t++;
                    }
                }
                rep(j, 1<<(i+1)) {
                    vector<ll> b;
                    rep(k, 1<<(i+1)) {
                        b.pub(t);
                        t++;
                    }
                    ans[i].pub(b);
                }
                rep(j, 1<<(i+1)) {
                    rep(k, 1 << (i+1)) {
                        ans[i][j + (1<<(i+1))].pub(ans[i][j][k] + t);
                    }
                }
            }
        }
        rep(i, ans[N - 1].size()) {
            rep(j, ans[N - 1][i].size()) {
                cout << ans[N - 1][i][j] << " ";
            }
            cout << endl;
        }
    }
}






0