結果
問題 | No.2991 Hypercubic Graph Flow |
ユーザー |
![]() |
提出日時 | 2024-12-16 17:02:18 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 79 ms / 2,000 ms |
コード長 | 843 bytes |
コンパイル時間 | 2,051 ms |
コンパイル使用メモリ | 197,620 KB |
最終ジャッジ日時 | 2025-02-26 14:45:48 |
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
ソースコード
#include <bits/stdc++.h> using namespace std; void fast_io() { ios::sync_with_stdio(false); std::cin.tie(nullptr); } int main() { fast_io(); int n; cin >> n; if (n == 1) { cout << "No" << endl; return 0; } cout << "Yes" << endl; vector<vector<int>> ans(1 << n, vector<int>(1 << n)); for (int i = 0; i < (1 << n); i++) { for (int j = 0; j < n; j++) { if (j % 2 == __builtin_popcount(i) % 2) { ans[i][i ^ (1 << j)] = 1; } else { ans[i][i ^ (1 << j)] = -1; } if (n % 2) { if (j == n - 2) { ans[i][i ^ (1 << (n - 1))] *= -1; } if (j == n - 1) { ans[i][i ^ (1 << (n - 2))] *= 2; } } } } for (int i = 0; i < (1 << n); i++) { long long su = 0; for (int j = 0; j < (1 << n); j++) { cout << ans[i][j] << " "; su += ans[i][j]; } cout << "\n"; assert(su == 0); } }