結果
| 問題 |
No.2212 One XOR Matrix
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2024-07-05 13:36:58 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,356 bytes |
| コンパイル時間 | 309 ms |
| コンパイル使用メモリ | 42,624 KB |
| 最終ジャッジ日時 | 2025-02-22 02:13:39 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | WA * 8 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:53:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
53 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*-
*
* 2212.cc: No.2212 One XOR Matrix - yukicoder
*/
#include<cstdio>
#include<algorithm>
using namespace std;
/* constant */
const int MAX_N = 10;
const int NBITS = 1 << MAX_N;
const int M = 4;
const int MMSK = (1 << M) - 1;
const int bs[M][M] = {
{ 7, 14, 0, 8},
{ 4, 12, 2, 11},
{15, 9, 6, 1},
{13, 10, 5, 3},
};
/* typedef */
/* global variables */
int as[NBITS][NBITS];
/* subroutines */
void check(int n) {
int nbits = 1 << n;
for (int i = 0; i < nbits; i++) {
int x = 0;
for (int j = 0; j < nbits; j++) x ^= as[i][j];
printf(" %d", x);
}
putchar('\n');
for (int j = 0; j < nbits; j++) {
int x = 0;
for (int i = 0; i < nbits; i++) x ^= as[i][j];
printf(" %d", x);
}
putchar('\n');
}
/* main */
int main() {
int n;
scanf("%d", &n);
if (n & 1) { puts("-1"); return 0; }
int nbits = 1 << n;
for (int i = 0, x = 0; i < nbits; i++)
for (int j = 0; j < nbits; j++, x++) as[i][j] = x;
//check(n);
for (int i0 = 0; i0 < nbits; i0 += M)
for (int i = 0; i < M; i++)
for (int j = 0; j < M; j++)
as[i0 + i][i0 + j] = (as[i0 + i][i0 + j] & ~MMSK) | bs[i][j];
//check(n);
for (int i = 0, x = 0; i < nbits; i++)
for (int j = 0; j < nbits; j++, x++)
printf("%d%c", as[i][j], (j + 1 < nbits) ? ' ' : '\n');
return 0;
}
tnakao0123