結果

問題 No.2991 Hypercubic Graph Flow
コンテスト
ユーザー tnakao0123
提出日時 2024-12-16 19:56:57
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 899 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 158 ms
コンパイル使用メモリ 53,604 KB
実行使用メモリ 9,272 KB
最終ジャッジ日時 2026-07-06 08:39:29
合計ジャッジ時間 2,850 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 1 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

/* -*- coding: utf-8 -*-
 *
 * 2991.cc:  No.2991 Hypercubic Graph Flow - yukicoder
 */

#include<cstdio>
#include<algorithm>

using namespace std;

/* constant */

const int MAX_N = 10;
const int NBITS = 1 << MAX_N;

/* typedef */

/* global variables */

int as[MAX_N], fs[NBITS][NBITS];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);
  if (n == 1) { puts("No"); return 0; }

  if (n & 1) {
    as[0] = 2, as[1] = as[2] = -1;
    for (int i = 3; i < n; i++)
      as[i] = (i & 1) * 2 - 1;
  }
  else {
    for (int i = 0; i < n; i++)
      as[i] = 1 - (i & 1) * 2;
  }
  
  int nbits = 1 << n;
  for (int i = 0; i < nbits; i++)
    for (int j = 0, bj = 1; j < n; j++, bj <<= 1)
      fs[i][i ^ bj] = as[j];

  puts("Yes");
  for (int i = 0; i < nbits; i++)
    for (int j = 0; j < nbits; j++)
      printf("%d%c", fs[i][j], (j + 1 < nbits) ? ' ' : '\n');
  
  return 0;
}
0