結果
問題 | No.2212 One XOR Matrix |
ユーザー | ripity |
提出日時 | 2023-02-10 23:19:41 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 104 ms / 2,000 ms |
コード長 | 1,420 bytes |
コンパイル時間 | 3,601 ms |
コンパイル使用メモリ | 231,460 KB |
実行使用メモリ | 8,272 KB |
最終ジャッジ日時 | 2023-09-22 00:22:34 |
合計ジャッジ時間 | 5,859 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,380 KB |
testcase_02 | AC | 2 ms
4,384 KB |
testcase_03 | AC | 2 ms
4,376 KB |
testcase_04 | AC | 1 ms
4,380 KB |
testcase_05 | AC | 2 ms
4,380 KB |
testcase_06 | AC | 4 ms
4,384 KB |
testcase_07 | AC | 8 ms
4,380 KB |
testcase_08 | AC | 27 ms
4,376 KB |
testcase_09 | AC | 104 ms
8,272 KB |
ソースコード
#pragma GCC target("avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; if( N == 1 ) { cout << -1 << endl; }else { vector<vector<int>> A = { { 7, 14, 0, 8}, { 4, 12, 2, 11}, {15, 9, 6, 1}, {13, 10, 5, 3} }; for( int n = 2; n < N; n++ ) { vector<vector<int>> B(1<<n, vector<int>(1<<n)); for( int i = 0; i < (1<<n); i++ ) { for( int j = 0; j < (1<<n); j++ ) { B[i][j] = (1<<(2*n))+i*(1<<n)+j; } sort(B[i].begin(), B[i].end(), [](const int& x, const int& y) { return (x&1) < (y&1); }); for( int j = 0; j < (1<<n); j++ ) { A[i].emplace_back(B[i][j]); } A.emplace_back(A[i]); } for( int i = (1<<n); i < (1<<(n+1)); i++ ) { reverse(A[i].begin(), A[i].end()); for( int j = 0; j < (1<<(n+1)); j++ ) { A[i][j] += (1<<(2*n+1)); } } } for( int i = 0; i < (1<<N); i++ ) { for( int j = 0; j < (1<<N); j++ ) { cout << A[i][j] << " "; } cout << "\n"; } } }