提交记录 175311
| 提交时间 |
评测时间 |
| 2026-11-18 22:57:41 |
2026-11-18 22:57:44 |
/* References
* saffah_codex_maker https://duck.ac/submission/162286 (FKM/Lyndon concatenation).
* saffah_v41f1017_agg4 https://duck.ac/submission/165115 and
* saffah_codex_6a_agg3 https://duck.ac/submission/165341 (compile-time output and streaming stores).
* saffah_codex61s_agg5 https://duck.ac/submission/166605 (full order-24 table).
* Those public solutions identify no separate license. Only algorithmic ideas used;
* the checkpoint program, bit-packing generator and transfer loop are independently written.
*
* Approach: At arbitrary 32 KiB boundaries save only the current extended necklace
* and its remaining bit count. Reconstruct each independent block in 64-bit units.
* Place independently computed blocks into one page-aligned ascending image and copy pairs of cache lines with a 512-byte outer loop.
* Experiment: measure continuous source addresses and the wider store loop on the judge.
*/
#include <cstdint>
#include <immintrin.h>
#pragma GCC target("avx2")
constexpr unsigned order = 21;
constexpr unsigned block_size = 32768;
struct alignas(64) Block { uint64_t words[block_size / 8]; };
constexpr Block materialize(uint32_t word, unsigned available) {
Block result{};
unsigned period = order;
for (auto &out : result.words) {
uint64_t bits = 0;
unsigned space = 64;
while (space != 0) {
if (available == 0) {
do {
++word;
period = order - __builtin_ctz(word);
for (unsigned distance = period; distance < order; distance *= 2)
word |= word >> distance;
} while (order % period != 0);
available = period;
}
unsigned count = available < space ? available : space;
available -= count;
space -= count;
uint32_t fragment = word >> (order - period + available);
bits = (bits << count) | (fragment & ((uint32_t(1) << count) - 1));
}
out = __builtin_bswap64(bits);
}
return result;
}
static constexpr Block b0 = materialize(0u, 1);
static constexpr Block b1 = materialize(25671u, 7);
static constexpr Block b2 = materialize(53597u, 13);
static constexpr Block b3 = materialize(85595u, 19);
static constexpr Block b4 = materialize(120295u, 4);
static constexpr Block b5 = materialize(169679u, 10);
static constexpr Block b6 = materialize(223865u, 2);
static constexpr Block b7 = materialize(338863u, 18);
alignas(4096) static const Block image[] = {b0,b1,b2,b3,b4,b5,b6,b7};
void debruijn(unsigned, char *out) {
const char *in = reinterpret_cast<const char *>(image);
for (unsigned i=0; i<sizeof(image); i+=512) {
for(unsigned j=0;j<512;j+=64){
auto x = _mm256_load_si256(reinterpret_cast<const __m256i*>(in+i+j));
auto y = _mm256_load_si256(reinterpret_cast<const __m256i*>(in+i+j+32));
_mm256_stream_si256(reinterpret_cast<__m256i*>(out+i+j),x);
_mm256_stream_si256(reinterpret_cast<__m256i*>(out+i+j+32),y);
}
}
_mm_sfence();
}
| Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
| Testcase #1 | 50.2 us | 264 KB | Accepted | Score: 100 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2026-11-23 12:28:23 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠