結果
| 問題 |
No.2991 Hypercubic Graph Flow
|
| コンテスト | |
| ユーザー |
umezo
|
| 提出日時 | 2024-12-16 08:40:18 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,282 bytes |
| コンパイル時間 | 3,567 ms |
| コンパイル使用メモリ | 250,848 KB |
| 実行使用メモリ | 8,448 KB |
| 最終ジャッジ日時 | 2024-12-16 08:40:23 |
| 合計ジャッジ時間 | 4,614 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 2 WA * 8 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
template <class T> using V=vector<T>;
template <class T> using VV=V<V<T>>;
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
auto f=[&](auto f,int n)->VV<int>{
if(n==1){
VV<int> A(2,V<int>(2));
A[0][1]=1,A[1][0]=1;
return A;
}
auto B=f(f,n-1);
int N=(1<<n);
VV<int> C(N,V<int>(N));
rep(i,N/2) rep(j,N/2){
C[i][j]=B[i][j];
C[i+N/2][j+N/2]=B[i][j];
}
rep(i,N/2) C[i][i+N/2]=1;
for(int i=N/2;i<N;i++) C[i][i-N/2]=1;
return C;
};
int n;
cin>>n;
if(n==1){
cout<<"No\n";
return 0;
}
auto A=f(f,n);
int N=(1<<n);
if(n%2==0){
int now=1;
rep(i,N/2) rep(j,N/2){
if(A[i][j]!=0){
A[i][j]=now;
A[i+N/2][j+N/2]=-now;
now*=-1;
}
}
rep(i,N/2){
int cnt=0;
rep(j,N){
if(j<N/2) cnt+=A[i][j];
if(j>=N/2 && A[i][j]==1){
A[i][j]=-cnt;
A[j][i]=cnt;
}
}
}
}
else{
}
cout<<"Yes\n";
rep(i,N){
rep(j,N){
if(j) cout<<" ";
cout<<A[i][j];
}
cout<<'\n';
}
return 0;
}
umezo