結果
| 問題 | No.3739 Stronger Network |
| コンテスト | |
| ユーザー |
てんぷら
|
| 提出日時 | 2026-09-19 17:13:53 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
WA
不安定
|
| 実行時間 | - |
| コード長 | 1,881 bytes |
| 記録 | |
| コンパイル時間 | 2,391 ms |
| コンパイル使用メモリ | 337,772 KB |
| 実行使用メモリ | 9,928 KB |
| 最終ジャッジ日時 | 2026-09-19 17:14:01 |
| 合計ジャッジ時間 | 5,559 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 32 WA * 16 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#ifdef TEMPURA
#else
#define debug(...) ((void)0)
#define msg(...) ((void)0)
#endif
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
using ll = long long;
using ull = unsigned long long;
using i128 = __int128_t;
template <class T>
inline bool chmin(T &a, T b) {
if(a > b) {
a = b;
return true;
}
return false;
}
template <class T>
inline bool chmax(T &a, T b) {
if(a < b) {
a = b;
return true;
}
return false;
}
// #include <atcoder/modint>
// using mint = atcoder::modint998244353;
vector<int> create_permutation(int n) {
assert(n % 2 == 0);
int b = 0;
while((1 << (b + 1)) <= n) {
b += 1;
}
vector<int> ret;
int cur = 0;
rep(i, (1 << b)) {
ret.push_back(cur);
if(i % 2 == 0) {
if((cur ^ (1 << b)) < n) {
ret.push_back(cur ^ (1 << b));
ret.push_back(cur ^ (1 << b) ^ 1);
}
}
int c = countr_zero(unsigned(i + 1));
cur ^= 1 << c;
}
debug(ret);
return ret;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int h, w;
cin >> h >> w;
if(h % 2 == 1 || w % 2 == 1) {
cout << -1 << endl;
return 0;
}
auto vh = create_permutation(h), vw = create_permutation(w);
int bh = 32 - countl_zero(unsigned(h - 1)), bw = 32 - countl_zero(unsigned(w - 1));
debug(bh, bw);
int ma1 = ((h - 1) << bw) + w - 1, ma2 = ((w - 1) << bh) + h - 1;
if(ma1 < ma2) {
rep(i, h) {
rep(j, w) cout << ((vh[i] << bw) + vw[j]) << " \n"[j + 1 == w];
}
} else {
rep(i, h) {
rep(j, w) cout << (vh[i] + (vw[j] << bh)) << " \n"[j + 1 == w];
}
}
return 0;
}
てんぷら