結果
| 問題 |
No.2991 Hypercubic Graph Flow
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-12-16 03:27:35 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 63 ms / 2,000 ms |
| コード長 | 1,254 bytes |
| コンパイル時間 | 2,146 ms |
| コンパイル使用メモリ | 199,344 KB |
| 最終ジャッジ日時 | 2025-02-26 14:42:22 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
ソースコード
#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;
if(n == 1){
cout << "No\n";
return 0;
}
r = 1 << n;
vector<vector<int>> A(r, vector<int>(r));
cout << "Yes\n";
if(n % 2 == 1){
vector<int> a(n - 3, 1);
for(int i = 1; i < a.size(); i += 2) a[i] *= -1;
a.emplace_back(1);
a.emplace_back(1);
a.emplace_back(-2);
for(int S = 0; S < r; S++){
for(int b = 0; b < n; b++){
A[S][S ^ (1 << b)] = __builtin_parity(S) ? -a[b] : a[b];
}
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';
}
}
/*for(int S = 0; S < r; S++){
for(int T = 0; T < r; T++){
assert(A[S][T] == -A[T][S]);
}
}*/
}