結果
問題 | No.2991 Hypercubic Graph Flow |
ユーザー |
![]() |
提出日時 | 2024-12-16 20:12:53 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 99 ms / 2,000 ms |
コード長 | 1,312 bytes |
コンパイル時間 | 421 ms |
コンパイル使用メモリ | 41,728 KB |
最終ジャッジ日時 | 2025-02-26 14:47:45 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:41:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 41 | scanf("%d", &n); | ~~~~~^~~~~~~~~~
ソースコード
/* -*- 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 */bool check(int n) {int nbits = 1 << n;for (int i = 0; i < nbits; i++) {int sum = 0;for (int j = 0; j < nbits; j++) {sum += fs[i][j];if (fs[i][j] != -fs[j][i]) return false;}if (sum != 0) return false;}return true;}/* 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++) {int bn = 0;for (int j = 0; j < n; j++) bn += ((i >> j) & 1);for (int j = 0, bj = 1; j < n; j++, bj <<= 1)fs[i][i ^ bj] = as[j] * (1 - (bn & 1) * 2);}puts("Yes");for (int i = 0; i < nbits; i++)for (int j = 0; j < nbits; j++)printf("%2d%c", fs[i][j], (j + 1 < nbits) ? ' ' : '\n');//if (check(n)) puts("OK");//else puts("NG");return 0;}