結果

問題 No.2212 One XOR Matrix
ユーザー 👑 chro_96chro_96
提出日時 2023-02-10 22:59:26
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 91 ms / 2,000 ms
コード長 816 bytes
コンパイル時間 1,285 ms
コンパイル使用メモリ 29,024 KB
実行使用メモリ 5,976 KB
最終ジャッジ日時 2023-09-22 00:08:19
合計ジャッジ時間 3,614 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,936 KB
testcase_01 AC 3 ms
5,860 KB
testcase_02 AC 3 ms
5,976 KB
testcase_03 AC 3 ms
5,936 KB
testcase_04 AC 2 ms
5,816 KB
testcase_05 AC 3 ms
5,928 KB
testcase_06 AC 4 ms
5,816 KB
testcase_07 AC 9 ms
5,872 KB
testcase_08 AC 25 ms
5,932 KB
testcase_09 AC 91 ms
5,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int main () {
  int n = 0;
  
  int res = 0;
  
  int a[1024][1024] = {};
  
  res = scanf("%d", &n);
  
  if (n <= 1) {
    printf("-1\n");
    return 0;
  }
  
  for (int i = 0; i < (1<<n); i++) {
    for (int j = 0; j < (1<<n); j++) {
      a[i][j] = ((i<<n)|j);
    }
  }
  
  for (int i = 0; i < (1<<(n-1)); i++) {
    int swap = a[2*i][(2*(i+1))%(1<<n)];
    a[2*i][(2*(i+1))%(1<<n)] = a[2*i+1][(2*(i+1))%(1<<n)];
    a[2*i+1][(2*(i+1))%(1<<n)] = swap;
    a[2*i][2*i] = ((2*i)<<n)+2*i+1;
    a[2*i][2*i+1] = ((2*i+1)<<n)+2*i+1;
    a[2*i+1][2*i] = ((2*i+1)<<n)+2*i;
    a[2*i+1][2*i+1] = ((2*i)<<n)+2*i;
  }
  
  for (int i = 0; i < (1<<n); i++) {
    printf("%d", a[i][0]);
    for (int j = 1; j < (1<<n); j++) {
      printf(" %d", a[i][j]);
    }
    printf("\n");
  }
  
  return 0;
}
0