結果

問題 No.2991 Hypercubic Graph Flow
ユーザー t98slider
提出日時 2024-12-16 03:20:19
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 968 bytes
コンパイル時間 2,068 ms
コンパイル使用メモリ 197,468 KB
最終ジャッジ日時 2025-02-26 14:42:13
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 6 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

template<class T> ostream& operator << (ostream& os, const vector<T>& vec) {
    if(vec.empty()) return os;
    os << vec[0];
    for(auto it = vec.begin(); ++it != vec.end(); ) os << ' ' << *it;
    return os;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, r;
    cin >> n;
    r = 1 << n;
    vector<vector<int>> A(r, vector<int>(r));
    cout << "Yes\n";
    if(n % 2 == 1){
        for(int S = 0; S < r; S++){
            for(int b = 0; b + 1 < n; b++){
                A[S][S ^ (1 << b)] = __builtin_parity(S) ? -1 : 1;
            }
            A[S][S ^ (1 << (n - 1))] = (__builtin_parity(S) ? 1 : -1) * (n - 1);
            cout << A[S] << '\n';
        }
    }else{
        for(int S = 0; S < r; S++){
            for(int b = 0; b < n; b++){
                A[S][S ^ (1 << b)] = (__builtin_parity(S) ^ b) & 1 ? -1 : 1;
            }
            cout << A[S] << '\n';
        }
    }
}
0