/* References / 引用: saffah_codex_6a_agg3 https://duck.ac/submission/166415:
complete mathematical order24 ROM and non-temporal streaming baseline;
retain all inherited authors, exact URLs and complete legal notices below.
Approach / 思路: Test output alignment once for the entire2MiB, retaining
the parent's exact unaligned fallback. Copy1024 bytes per unrolled body
with one explicit256-bit load/store pair per vector,
eliminating per4096-byte repeated alignment peels and tails. Preserve exact
mathematical constants, every output byte and final SFENCE.
Experiment purpose: five complete2MiB comparisons against original FKM,
guards64, then immediate official measurement without local timing filter.
*/
/* References: saffah_codex61s_agg5 https://duck.ac/submission/165993 supplies the complete mathematical2MiB constant sequence and independent4096-byte constant blocks; saffah_codex_6a_agg3 https://duck.ac/submission/165868 supplies the aligned NT256-byte streaming copy. All inherited authors, complete source URLs and licence notices below retained.
Idea: copy the entire precomputed order24 sequence with aligned non-temporal256-byte streaming stores, retaining exact scalar alignment peels and tails, and fence before returning. This combines complete compile-time sequence materialization with avoiding output cache allocation on the entire2MiB; no runtime recurrence remains.
Experiment purpose: every output byte, all cyclic24-bit windows, five alignments and guards, then official timing. */
/* References / 引用: saffah_codex_6a_agg3
https://duck.ac/submission/165375: complete separate-constexpr prefix and
paired-word continuation. Every inherited account/source/license notice is
retained below. Public Duck sources state no additional license.
Approach / 思路: Materialize the entire mathematical sequence and omit all runtime FKM continuation. Copy the complete byte-correct constant blocks directly.
Reduce actual constant-evaluator work: construct each four-word payload from a replicated64-bit pair plus one constant, combine the leading-bit guard into one mask, use a divisor bitmask and one direct repeat shift for long periods.
During constant evaluation, recognize aligned leading00 fusion runs and concatenate four exact full-length words into one128-bit payload, reducing repeated recurrence/reader work while producing identical ROM.
Independently advance the exact FKM bit reader to2097152
mathematical prefix bytes, recording checkpoints at4096-byte boundaries.
Materialize each bounded block as a separate constant object and resume
the parent engine from the exact remaining fragment/current Lyndon state.
This extends the actual precomputed prefix without a monolithic aggregate.
Experiment purpose: validate all2097152 output bytes and64 tail
guards, then immediately obtain the official compiler and runtime result.
Local compilation resources or speed do not replace official evidence.
*/
/* References / 引用: saffah_v41f1017_agg4 https://duck.ac/submission/163049: latest paired-word FKM recurrence, constant tail advances and safe-end convention, adapted with inherited notices below. saffah_codex_6a_agg3 https://duck.ac/submission/162692: original adjacent-full-word fusion.
Idea / 思路: A single boundary check selects a hot loop whose complete8/16byte stores remain inside the output. Combine both full-length words into one append even at orders30/33 using a128bit register payload, rather than emitting twice. Constant trailing-ones advances2..7 skip impossible proper periods; short final output uses exact byte copies.
Experiment purpose / 试验目的: Verify every output byte for all five full orders, plus independent recursive FKM/cyclic uniqueness for3..16, then submit each currently unmet order. */
/* 引用: 原账号 saffah_codex_maker, 原始提交 https://duck.ac/submission/162286 (FKM/Lyndon
* 打包生成器完整代码); 采纳链 saffah_codex61s_agg5 https://duck.ac/submission/162839 的
* 双词 2N 位合并发射, 以及本账号 https://duck.ac/submission/162770 的 ctz(word+1)/safe_end/
* 寄存器尾写。本文件另把非常短词的一段式广播级联扩展到 N-4/N-5, 输出逐字节不变。
* 许可证: 该公开代码未声明独立许可证, 保留原注释与署名。
* 目的: 在本账号下以官网测量复核 n=21 的字典序最小 de Bruijn 序列打包输出。*/
/* References / 引用:
saffah_codex_6a_agg3 https://duck.ac/submission/163200: reference the exact
next-word/TZCNT/repeated-period FKM recurrence, with its complete source and
account attribution chain retained above. saffah_codex61s_agg5
https://duck.ac/submission/164939: own bounded constexpr-chunk mathematical
answer approach; here the FKM state is checkpointed instead of storing bits.
Additional reference: saffah_v41f1017_agg4
https://duck.ac/submission/165008: copied the latest complete paired-word/run-loop runtime FKM continuation
and bounded stores, preserving its complete inherited notices below.
Approach / 思路: Cache the first1048576 mathematical bytes through
independent constexpr checkpoints, then resume the accepted paired-word
engine at the exact Lyndon state. Emit any unconsumed pending fragment first
and retain the original full-width hot loop and byte-safe end. Only a prefix
is materialized, reducing compiler work; every remaining bit is generated by
the exact recurrence. Validate the complete sequence including the join.
Experiment purpose: compare every order27 output byte with the original
accepted FKM generator and guard64, then obtain official compiler/runtime
results immediately. No local performance filter or compiler-limit assumption.
*/
/* 引用 / References: saffah_codex_6a_agg3 https://duck.ac/submission/163806 : 完整
* paired-boundary packed-FKM 引擎与全部继承注释 (该公开代码未声明独立许可证, 保留引用链).
* 本实现改动 / Change: 把四词融合的连续段串成一个 run loop —— 融合后参考推进为
* word=(w+8)|((w+8)>>p), p=N-ctz(w+8); 当该填充为恒等时下一状态恰为 w+8 且下一迭代同样
* 满足融合条件, 于是整段只需循环 "双次 put<2N> + 边界测试", 省去每个融合迭代的融合判定与
* 六路尾一分支级联. 输出逐字节不变, 仅缩短控制流.
* 目的 / Purpose: 在官网 (小阶更偏计算密集) 复核该 run-loop 是否快于引用版本.
*/
/* References: saffah_codex61s_agg5 https://duck.ac/submission/163502 : four-word generation shortcut and complete packed FKM engine, with all inherited notices retained.
Idea: within its existing low3-zero shortcut, replicate the unchanged base word into2or4 lanes and OR only the known odd low-bit constants. Reuse one doubled base for both order27 appends, and double it again for the order30 payload. This removes separately constructing word+1,+3,+5,+7 and retains the established branch frequency and store bounds. Experiment purpose: reduce payload instruction count after the larger16-word branch was measured negative; validate every target output byte and independent small-order FKM before official measurement. */
/* References / 引用:
saffah_codex_6a_agg3 https://duck.ac/submission/163203: complete latest
paired-word packed FKM engine, stores, boundary handling and attribution chain.
All inherited original comments retained; public source states no additional
license. saffah_codex_maker https://duck.ac/submission/162342: original FKM
generator used independently for full-output correctness.
Approach / 思路: When low3 bits are000 and the leading2 bits are00, the N-2 single-fill advance contributes zero bits. The next four full-length words are therefore word+1,+3,+5,+7. Append their4*N bits through two compile-time2*N-bit narrow64-bit appends instead of constructing a128-bit payload, then retain the exact original advance from word+7. This avoids one complete generator iteration per group.
Preserve word pairing, all emitted bits, bounded stores and byte-safe tail.
Experiment purpose / 试验目的: Full order27 byte-for-byte versus original
accepted reference with64-byte guards, then immediate official timing.
Local timing never filters a candidate.
*/
/* References / 引用: saffah_v41f1017_agg4 https://duck.ac/submission/163062: latest paired-word FKM recurrence, constant tail advances and safe-end convention, adapted with inherited notices below. saffah_codex_6a_agg3 https://duck.ac/submission/162692: original adjacent-full-word fusion.
Idea / 思路: A single boundary check selects a hot loop whose complete8/16byte stores remain inside the output. Combine both full-length words into one append even at orders30/33 using a128bit register payload, rather than emitting twice. Constant trailing-ones advances2..7 skip impossible proper periods; short final output uses exact byte copies.
Experiment purpose / 试验目的: Verify every output byte for all five full orders, plus independent recursive FKM/cyclic uniqueness for3..16, then submit each currently unmet order. */
/* 引用: 原账号 saffah_codex_maker, 原始提交 https://duck.ac/submission/162286 (FKM/Lyndon
* 打包生成器完整代码); 采纳链 saffah_codex61s_agg5 https://duck.ac/submission/162848 的
* 双词 2N 位合并发射, 以及本账号 https://duck.ac/submission/162770 的 ctz(word+1)/safe_end/
* 寄存器尾写。本文件另把非常短词的一段式广播级联扩展到 N-4/N-5, 输出逐字节不变。
* 许可证: 该公开代码未声明独立许可证, 保留原注释与署名。
* 目的: 在本账号下以官网测量复核 n=27 的字典序最小 de Bruijn 序列打包输出。*/
/* References / 引用: saffah_codex61s_agg5 https://duck.ac/submission/165061:
bounded 512-word constexpr checkpoint generator and exact continuation fragment,
adapted below. saffah_v41f1017_agg4 https://duck.ac/submission/165297:
prefix precomputation and paired-word FKM continuation, inherited chain follows.
saffah_codex_6a_agg3 https://duck.ac/submission/163202 and
https://duck.ac/submission/162692: paired-word fusion and bounded output writes.
saffah_codex_maker https://duck.ac/submission/162286: original packed FKM recurrence.
No separate licence stated in these public submissions; source attribution retained.
Idea / 思路: Each 4096-byte mathematical output block is a separate constexpr
object evaluated from its exact FKM checkpoint. Store 64 output bits per constant
element, avoiding the compiler's large byte-array intermediate representation.
Cache a larger mathematical prefix (1048576 bytes in this order24 candidate)
and continue from the exact residual payload. Runtime copies independent blocks.
Experiment purpose: complete-byte independent FKM comparison, cyclic uniqueness
at order24, output-alignment and guards, followed by immediate official evaluation.
*/
#include<cstdint>
#include<cstddef>
#include<cstring>
#pragma GCC optimize("O3")
struct RootChunk{uint64_t values[512]{};};
constexpr RootChunk root_generate(uint64_t word,uint64_t initial,unsigned available){
using U=unsigned __int128;U payload=initial;RootChunk out{};
for(unsigned i=0;i<512;++i){uint64_t value=0;unsigned filled=0;
while(filled<64){while(!available){uint64_t next=word+1;unsigned period=24-__builtin_ctzll(next);
if((next&((UINT64_C(3)<<22)|7))==0&&(next>>period)==0){
uint64_t pair=(next<<24)|next;payload=(U(pair)<<48)|pair|(U(UINT64_C(256))<<64)|UINT64_C(844425014018055);word=next+7;available=96;
}else{word=next;if(period*2>24)word|=word>>period;else for(unsigned sh=period;sh<24;sh*=2)word|=word>>sh;if((UINT64_C(16781662)>>period)&1){payload=word>>(24-period);available=period;}}
}
unsigned take=64-filled<available?64-filled:available;uint64_t part=uint64_t(payload>>(available-take));
if(take<64){part&=(UINT64_C(1)<<take)-1;value=(value<<take)|part;}else value=part;
available-=take;filled+=take;
}out.values[i]=__builtin_bswap64(value);
}return out;
}
#define C(I,W,P,A) alignas(64) static constexpr RootChunk cache##I=root_generate(W,P,A);
C(0,0ull,0ull,1)
C(1,2731ull,2731ull,17)
C(2,5463ull,5463ull,21)
C(3,8197ull,8197ull,13)
C(4,10929ull,10929ull,5)
C(5,13663ull,13663ull,9)
C(6,16411ull,16411ull,1)
C(7,19147ull,19147ull,17)
C(8,21887ull,21887ull,21)
C(9,24633ull,24633ull,13)
C(10,27369ull,27369ull,5)
C(11,30111ull,30111ull,9)
C(12,32911ull,32911ull,1)
C(13,35655ull,35655ull,17)
C(14,38405ull,38405ull,21)
C(15,41165ull,41165ull,13)
C(16,43909ull,43909ull,5)
C(17,46661ull,46661ull,9)
C(18,49451ull,49451ull,1)
C(19,52199ull,52199ull,17)
C(20,54957ull,54957ull,21)
C(21,57729ull,57729ull,13)
C(22,60481ull,60481ull,5)
C(23,63237ull,63237ull,9)
C(24,66243ull,66243ull,9)
C(25,69005ull,69005ull,1)
C(26,71781ull,71781ull,5)
C(27,74571ull,74571ull,21)
C(28,77335ull,77335ull,13)
C(29,80113ull,80113ull,17)
C(30,82951ull,82951ull,9)
C(31,85713ull,85713ull,1)
C(32,88497ull,88497ull,5)
C(33,91301ull,91301ull,21)
C(34,94067ull,94067ull,13)
C(35,96855ull,96855ull,17)
C(36,99807ull,99807ull,9)
C(37,102603ull,102603ull,13)
C(38,105375ull,105375ull,5)
C(39,108193ull,108193ull,21)
C(40,110989ull,110989ull,1)
C(41,113769ull,113769ull,17)
C(42,116643ull,116643ull,9)
C(43,119447ull,119447ull,13)
C(44,122227ull,122227ull,5)
C(45,125065ull,125065ull,21)
C(46,127857ull,127857ull,1)
C(47,130643ull,130643ull,17)
C(48,134467ull,134467ull,9)
C(49,137299ull,137299ull,13)
C(50,140151ull,140151ull,5)
C(51,142961ull,142961ull,21)
C(52,145795ull,145795ull,1)
C(53,148731ull,148731ull,17)
C(54,151535ull,151535ull,9)
C(55,154377ull,154377ull,13)
C(56,157247ull,157247ull,5)
C(57,160089ull,160089ull,9)
C(58,162903ull,162903ull,1)
C(59,166035ull,166035ull,17)
C(60,168869ull,168869ull,21)
C(61,171689ull,171689ull,13)
C(62,174581ull,174581ull,5)
C(63,177427ull,177427ull,9)
C(64,180415ull,180415ull,1)
C(65,183233ull,183233ull,17)
C(66,186083ull,186083ull,21)
C(67,188991ull,188991ull,13)
C(68,191815ull,191815ull,5)
C(69,194679ull,194679ull,9)
C(70,198257ull,198257ull,9)
C(71,201133ull,201133ull,13)
C(72,203971ull,203971ull,5)
C(73,206905ull,206905ull,21)
C(74,209761ull,209761ull,1)
C(75,212603ull,212603ull,17)
C(76,215645ull,215645ull,9)
C(77,218517ull,218517ull,13)
C(78,221459ull,221459ull,5)
C(79,224307ull,224307ull,21)
C(80,227169ull,227169ull,1)
C(81,230467ull,230467ull,17)
C(82,233309ull,233309ull,9)
C(83,236207ull,236207ull,13)
C(84,239151ull,239151ull,5)
C(85,242047ull,242047ull,9)
C(86,244903ull,244903ull,1)
C(87,247991ull,247991ull,17)
C(88,250869ull,250869ull,21)
C(89,253731ull,253731ull,13)
C(90,256701ull,256701ull,5)
C(91,259597ull,259597ull,9)
C(92,266603ull,266603ull,7)
C(93,269513ull,269513ull,23)
C(94,272539ull,272539ull,15)
C(95,275483ull,275483ull,19)
C(96,278379ull,278379ull,11)
C(97,281547ull,281547ull,3)
C(98,284497ull,284497ull,7)
C(99,287535ull,287535ull,23)
C(100,290451ull,290451ull,15)
C(101,293421ull,293421ull,19)
C(102,296875ull,296875ull,11)
C(103,299855ull,299855ull,15)
C(104,302775ull,302775ull,7)
C(105,305833ull,305833ull,23)
C(106,308793ull,308793ull,3)
C(107,312007ull,312007ull,19)
C(108,314935ull,314935ull,11)
C(109,317915ull,317915ull,15)
C(110,320963ull,320963ull,7)
C(111,323953ull,323953ull,11)
C(112,326883ull,326883ull,3)
C(113,331089ull,331089ull,3)
C(114,334095ull,334095ull,7)
C(115,337165ull,337165ull,23)
C(116,340169ull,340169ull,3)
C(117,343117ull,343117ull,19)
C(118,346381ull,346381ull,11)
C(119,349369ull,349369ull,15)
C(120,352471ull,352471ull,7)
C(121,355425ull,355425ull,23)
C(122,358397ull,358397ull,3)
C(123,362059ull,362059ull,19)
C(124,365085ull,365085ull,23)
C(125,368033ull,368033ull,15)
C(126,371153ull,371153ull,7)
C(127,374159ull,374159ull,11)
C(128,377471ull,377471ull,3)
C(129,380439ull,380439ull,19)
C(130,383463ull,383463ull,23)
C(131,386581ull,386581ull,15)
C(132,389609ull,389609ull,19)
C(133,392575ull,392575ull,11)
C(134,398683ull,398683ull,15)
C(135,401845ull,401845ull,7)
C(136,404839ull,404839ull,23)
C(137,407907ull,407907ull,3)
C(138,411257ull,411257ull,19)
C(139,414331ull,414331ull,23)
C(140,417329ull,417329ull,15)
C(141,420507ull,420507ull,7)
C(142,423559ull,423559ull,11)
C(143,427377ull,427377ull,3)
C(144,430463ull,430463ull,7)
C(145,433471ull,433471ull,23)
C(146,436665ull,436665ull,15)
C(147,439727ull,439727ull,19)
C(148,443153ull,443153ull,11)
C(149,446161ull,446161ull,3)
C(150,449255ull,449255ull,7)
C(151,452437ull,452437ull,23)
C(152,455533ull,455533ull,3)
C(153,458549ull,458549ull,19)
C(154,463453ull,463453ull,7)
C(155,466481ull,466481ull,23)
C(156,469711ull,469711ull,15)
C(157,472797ull,472797ull,19)
C(158,476287ull,476287ull,11)
C(159,479411ull,479411ull,15)
C(160,482445ull,482445ull,7)
C(161,485691ull,485691ull,23)
C(162,488785ull,488785ull,3)
C(163,492775ull,492775ull,19)
C(164,495915ull,495915ull,23)
C(165,498957ull,498957ull,15)
C(166,502215ull,502215ull,7)
C(167,505319ull,505319ull,11)
C(168,508843ull,508843ull,3)
C(169,511893ull,511893ull,19)
C(170,515035ull,515035ull,23)
C(171,518335ull,518335ull,15)
C(172,521449ull,521449ull,19)
C(173,541385ull,541385ull,11)
C(174,544539ull,544539ull,3)
C(175,547789ull,547789ull,7)
C(176,551209ull,551209ull,23)
C(177,554425ull,554425ull,3)
C(178,558651ull,558651ull,19)
C(179,561913ull,561913ull,23)
C(180,565077ull,565077ull,15)
C(181,568507ull,568507ull,7)
C(182,571781ull,571781ull,11)
C(183,575433ull,575433ull,3)
C(184,578737ull,578737ull,7)
C(185,582169ull,582169ull,23)
C(186,585335ull,585335ull,15)
C(187,588617ull,588617ull,19)
C(188,594167ull,594167ull,7)
C(189,597357ull,597357ull,23)
C(190,600805ull,600805ull,15)
C(191,604069ull,604069ull,19)
C(192,607843ull,607843ull,11)
C(193,611149ull,611149ull,15)
C(194,614335ull,614335ull,7)
C(195,617823ull,617823ull,23)
C(196,621141ull,621141ull,3)
C(197,625523ull,625523ull,19)
C(198,628873ull,628873ull,23)
C(199,632299ull,632299ull,15)
C(200,635633ull,635633ull,19)
C(201,638837ull,638837ull,11)
C(202,642663ull,642663ull,3)
C(203,645991ull,645991ull,7)
C(204,649513ull,649513ull,23)
C(205,652793ull,652793ull,3)
C(206,661145ull,661145ull,19)
C(207,664695ull,664695ull,11)
C(208,668061ull,668061ull,15)
C(209,671311ull,671311ull,7)
C(210,675191ull,675191ull,23)
C(211,678571ull,678571ull,3)
C(212,682143ull,682143ull,19)
C(213,685471ull,685471ull,23)
C(214,690033ull,690033ull,15)
C(215,693449ull,693449ull,19)
C(216,697015ull,697015ull,11)
C(217,700269ull,700269ull,3)
C(218,703689ull,703689ull,7)
C(219,707635ull,707635ull,23)
C(220,711021ull,711021ull,3)
C(221,714559ull,714559ull,19)
C(222,717991ull,717991ull,23)
C(223,724069ull,724069ull,23)
C(224,727479ull,727479ull,3)
C(225,731037ull,731037ull,19)
C(226,734493ull,734493ull,23)
C(227,738485ull,738485ull,15)
C(228,741925ull,741925ull,19)
C(229,745199ull,745199ull,11)
C(230,748849ull,748849ull,3)
C(231,752285ull,752285ull,7)
C(232,757047ull,757047ull,23)
C(233,760493ull,760493ull,3)
C(234,764151ull,764151ull,19)
C(235,767561ull,767561ull,23)
C(236,771609ull,771609ull,15)
C(237,775053ull,775053ull,19)
C(238,778723ull,778723ull,11)
C(239,782037ull,782037ull,3)
C(240,785527ull,785527ull,7)
C(241,801325ull,801325ull,5)
C(242,805459ull,805459ull,21)
C(243,808917ull,808917ull,1)
C(244,812687ull,812687ull,17)
C(245,816243ull,816243ull,21)
C(246,821161ull,821161ull,13)
C(247,824729ull,824729ull,17)
C(248,828515ull,828515ull,9)
C(249,832061ull,832061ull,13)
C(250,835435ull,835435ull,5)
C(251,839623ull,839623ull,21)
C(252,843197ull,843197ull,1)
C(253,847005ull,847005ull,17)
C(254,850559ull,850559ull,21)
C(255,857391ull,857391ull,9)
C(256,861165ull,861165ull,1)
C(257,864795ull,864795ull,5)
C(258,868195ull,868195ull,21)
C(259,872431ull,872431ull,13)
C(260,876069ull,876069ull,17)
C(261,879897ull,879897ull,9)
C(262,883485ull,883485ull,13)
C(263,888621ull,888621ull,5)
C(264,892247ull,892247ull,9)
C(265,896109ull,896109ull,1)
C(266,899711ull,899711ull,5)
C(267,904011ull,904011ull,21)
C(268,907643ull,907643ull,1)
C(269,911527ull,911527ull,17)
C(270,915085ull,915085ull,21)
C(271,925679ull,925679ull,13)
C(272,929605ull,929605ull,5)
C(273,933283ull,933283ull,9)
C(274,937659ull,937659ull,1)
C(275,941353ull,941353ull,5)
C(276,945289ull,945289ull,21)
C(277,948941ull,948941ull,1)
C(278,954263ull,954263ull,17)
C(279,957987ull,957987ull,21)
C(280,961915ull,961915ull,13)
C(281,965591ull,965591ull,17)
C(282,970061ull,970061ull,9)
C(283,973739ull,973739ull,13)
C(284,977713ull,977713ull,5)
C(285,981427ull,981427ull,9)
C(286,988899ull,988899ull,21)
C(287,992893ull,992893ull,13)
C(288,996645ull,996645ull,17)
C(289,1001129ull,1001129ull,9)
C(290,1004881ull,1004881ull,13)
C(291,1008883ull,1008883ull,5)
C(292,1012605ull,1012605ull,9)
C(293,1018215ull,1018215ull,1)
C(294,1021877ull,1021877ull,5)
C(295,1025911ull,1025911ull,21)
C(296,1029703ull,1029703ull,1)
C(297,1034221ull,1034221ull,17)
C(298,1038021ull,1038021ull,21)
C(299,1042071ull,1042071ull,13)
C(300,1045851ull,1045851ull,17)
C(301,1119339ull,1119339ull,13)
C(302,1123655ull,1123655ull,5)
C(303,1127715ull,1127715ull,9)
C(304,1132539ull,1132539ull,1)
C(305,1136607ull,1136607ull,5)
C(306,1141075ull,1141075ull,21)
C(307,1145143ull,1145143ull,1)
C(308,1151325ull,1151325ull,5)
C(309,1155693ull,1155693ull,21)
C(310,1159781ull,1159781ull,1)
C(311,1164711ull,1164711ull,17)
C(312,1168807ull,1168807ull,21)
C(313,1173191ull,1173191ull,13)
C(314,1177291ull,1177291ull,17)
C(315,1190485ull,1190485ull,9)
C(316,1194619ull,1194619ull,13)
C(317,1199615ull,1199615ull,5)
C(318,1203795ull,1203795ull,9)
C(319,1208221ull,1208221ull,1)
C(320,1212371ull,1212371ull,5)
C(321,1218899ull,1218899ull,9)
C(322,1223365ull,1223365ull,1)
C(323,1227543ull,1227543ull,5)
C(324,1232613ull,1232613ull,21)
C(325,1236795ull,1236795ull,1)
C(326,1241547ull,1241547ull,5)
C(327,1250299ull,1250299ull,5)
C(328,1254863ull,1254863ull,21)
C(329,1259095ull,1259095ull,1)
C(330,1264313ull,1264313ull,17)
C(331,1268535ull,1268535ull,21)
C(332,1273117ull,1273117ull,13)
C(333,1277335ull,1277335ull,17)
C(334,1283933ull,1283933ull,21)
C(335,1288611ull,1288611ull,13)
C(336,1292875ull,1292875ull,17)
C(337,1298075ull,1298075ull,9)
C(338,1302325ull,1302325ull,13)
C(339,1307207ull,1307207ull,17)
C(340,1331941ull,1331941ull,15)
C(341,1336649ull,1336649ull,7)
C(342,1341005ull,1341005ull,11)
C(343,1347931ull,1347931ull,15)
C(344,1352607ull,1352607ull,7)
C(345,1357021ull,1357021ull,11)
C(346,1362491ull,1362491ull,3)
C(347,1366855ull,1366855ull,7)
C(348,1371593ull,1371593ull,23)
C(349,1375977ull,1375977ull,3)
C(350,1386087ull,1386087ull,3)
C(351,1390483ull,1390483ull,7)
C(352,1396059ull,1396059ull,23)
C(353,1400479ull,1400479ull,3)
C(354,1405557ull,1405557ull,7)
C(355,1412435ull,1412435ull,23)
C(356,1416873ull,1416873ull,3)
C(357,1421981ull,1421981ull,7)
C(358,1427447ull,1427447ull,23)
C(359,1432043ull,1432043ull,3)
C(360,1436909ull,1436909ull,19)
C(361,1441383ull,1441383ull,23)
C(362,1457117ull,1457117ull,3)
C(363,1463035ull,1463035ull,7)
C(364,1467979ull,1467979ull,23)
C(365,1472467ull,1472467ull,3)
C(366,1479911ull,1479911ull,7)
C(367,1484783ull,1484783ull,23)
C(368,1489507ull,1489507ull,3)
C(369,1495471ull,1495471ull,7)
C(370,1500453ull,1500453ull,23)
C(371,1504997ull,1504997ull,3)
C(372,1515239ull,1515239ull,3)
C(373,1520539ull,1520539ull,7)
C(374,1526423ull,1526423ull,23)
C(375,1531061ull,1531061ull,3)
C(376,1536375ull,375ull,7)
C(377,1543659ull,1543659ull,23)
C(378,1548271ull,1548271ull,3)
C(379,1553709ull,1553709ull,7)
C(380,1559657ull,1559657ull,23)
C(381,1564281ull,1564281ull,3)
C(382,1569651ull,1569651ull,7)
C(383,1624819ull,1624819ull,23)
C(384,1629673ull,1629673ull,3)
C(385,1635257ull,1635257ull,7)
C(386,1646175ull,1646175ull,7)
C(387,1651839ull,1651839ull,11)
C(388,1658059ull,1658059ull,3)
C(389,1662905ull,1662905ull,7)
C(390,1668597ull,1668597ull,11)
C(391,1676723ull,1676723ull,15)
C(392,1682203ull,1682203ull,7)
C(393,1687151ull,1687151ull,11)
C(394,1693641ull,1693641ull,15)
C(395,1699191ull,1699191ull,7)
C(396,1717479ull,1717479ull,11)
C(397,1723851ull,1723851ull,3)
C(398,1729715ull,1729715ull,7)
C(399,1734653ull,1734653ull,11)
C(400,1743207ull,1743207ull,15)
C(401,1748691ull,1748691ull,7)
C(402,1755543ull,1755543ull,11)
C(403,1760617ull,1760617ull,15)
C(404,1766551ull,1766551ull,19)
C(405,1778939ull,1778939ull,19)
C(406,1784183ull,1784183ull,23)
C(407,1790939ull,1790939ull,3)
C(408,1796725ull,1796725ull,19)
C(409,1801855ull,1801855ull,23)
C(410,1810415ull,1810415ull,3)
C(411,1816447ull,1816447ull,7)
C(412,1823519ull,1823519ull,11)
C(413,1829307ull,1829307ull,3)
C(414,1834477ull,1834477ull,7)
C(415,1872381ull,1872381ull,17)
C(416,1878363ull,1878363ull,9)
C(417,1883645ull,1883645ull,13)
C(418,1890939ull,1890939ull,17)
C(419,1897165ull,1897165ull,21)
C(420,1910379ull,1910379ull,21)
C(421,1915853ull,1915853ull,1)
C(422,1923055ull,1923055ull,5)
C(423,1929131ull,1929131ull,21)
C(424,1938741ull,1938741ull,13)
C(425,1944813ull,1944813ull,5)
C(426,1952231ull,1952231ull,9)
C(427,1957691ull,1957691ull,13)
C(428,1964029ull,1964029ull,17)
C(429,1986525ull,1986525ull,9)
C(430,1993199ull,1993199ull,13)
C(431,1998745ull,1998745ull,17)
C(432,2009083ull,2009083ull,21)
C(433,2014893ull,2014893ull,1)
C(434,2022611ull,2022611ull,5)
C(435,2029165ull,2029165ull,9)
C(436,2043351ull,2043351ull,9)
C(437,2051071ull,2051071ull,13)
C(438,2057829ull,2057829ull,17)
C(439,2063675ull,2063675ull,21)
C(440,2074333ull,2074333ull,1)
C(441,2080211ull,2080211ull,5)
C(442,2088157ull,2088157ull,9)
C(443,2094845ull,2094845ull,13)
C(444,2401429ull,2401429ull,8)
C(445,2408245ull,2408245ull,12)
C(446,2418285ull,2418285ull,16)
C(447,2434543ull,2434543ull,4)
C(448,2443775ull,2443775ull,8)
C(449,2451877ull,2451877ull,12)
C(450,2463435ull,2463435ull,16)
C(451,2471571ull,2471571ull,20)
C(452,2480893ull,2480893ull,0)
C(453,2489069ull,2489069ull,4)
C(454,2516639ull,2516639ull,8)
C(455,2528687ull,2528687ull,12)
C(456,2537053ull,2537053ull,16)
C(457,2546619ull,2546619ull,20)
C(458,2555099ull,2555099ull,0)
C(459,2572253ull,2572253ull,12)
C(460,2583245ull,2583245ull,16)
C(461,2595643ull,2595643ull,20)
C(462,2604253ull,2604253ull,0)
C(463,2615099ull,2615099ull,4)
C(464,2707063ull,2707063ull,8)
C(465,2716541ull,2716541ull,0)
C(466,2730447ull,2730447ull,16)
C(467,2741183ull,2741183ull,8)
C(468,2750325ull,2750325ull,12)
C(469,2780767ull,2780767ull,4)
C(470,2795341ull,2795341ull,8)
C(471,2806621ull,2806621ull,0)
C(472,2815965ull,2815965ull,4)
C(473,2837877ull,2837877ull,16)
C(474,2847991ull,2847991ull,8)
C(475,2862685ull,2862685ull,0)
C(476,2874263ull,2874263ull,16)
C(477,2929579ull,2929579ull,2)
C(478,2940917ull,2940917ull,6)
C(479,2963037ull,2963037ull,6)
C(480,2976125ull,2976125ull,10)
C(481,2991959ull,2991959ull,14)
C(482,3004283ull,3004283ull,6)
C(483,3038427ull,3038427ull,10)
C(484,3054941ull,3054941ull,14)
C(485,3068915ull,3068915ull,6)
C(486,3079859ull,3079859ull,10)
C(487,3104687ull,3104687ull,10)
C(488,3123159ull,3123159ull,14)
C(489,3136511ull,3136511ull,6)
C(490,3357557ull,3357557ull,14)
C(491,3373565ull,3373565ull,6)
C(492,3395295ull,3395295ull,10)
C(493,3462495ull,3462495ull,8)
C(494,3489023ull,3489023ull,20)
C(495,3505983ull,3505983ull,12)
C(496,3529981ull,3529981ull,4)
C(497,3571671ull,3571671ull,20)
C(498,3596287ull,3596287ull,12)
C(499,3628763ull,3628763ull,12)
C(500,3652583ull,3652583ull,4)
C(501,3790319ull,3790319ull,8)
C(502,3844971ull,3844971ull,12)
C(503,3866347ull,3866347ull,16)
C(504,3911543ull,3911543ull,16)
C(505,3996541ull,3996541ull,2)
C(506,4045471ull,4045471ull,14)
C(507,4111343ull,4111343ull,18)
C(508,4160365ull,4160365ull,18)
C(509,5599167ull,5599167ull,0)
C(510,5729723ull,5729723ull,12)
C(511,6026999ull,6026999ull,0)
static const RootChunk* const blocks[]={&cache0,&cache1,&cache2,&cache3,&cache4,&cache5,&cache6,&cache7,&cache8,&cache9,&cache10,&cache11,&cache12,&cache13,&cache14,&cache15,&cache16,&cache17,&cache18,&cache19,&cache20,&cache21,&cache22,&cache23,&cache24,&cache25,&cache26,&cache27,&cache28,&cache29,&cache30,&cache31,&cache32,&cache33,&cache34,&cache35,&cache36,&cache37,&cache38,&cache39,&cache40,&cache41,&cache42,&cache43,&cache44,&cache45,&cache46,&cache47,&cache48,&cache49,&cache50,&cache51,&cache52,&cache53,&cache54,&cache55,&cache56,&cache57,&cache58,&cache59,&cache60,&cache61,&cache62,&cache63,&cache64,&cache65,&cache66,&cache67,&cache68,&cache69,&cache70,&cache71,&cache72,&cache73,&cache74,&cache75,&cache76,&cache77,&cache78,&cache79,&cache80,&cache81,&cache82,&cache83,&cache84,&cache85,&cache86,&cache87,&cache88,&cache89,&cache90,&cache91,&cache92,&cache93,&cache94,&cache95,&cache96,&cache97,&cache98,&cache99,&cache100,&cache101,&cache102,&cache103,&cache104,&cache105,&cache106,&cache107,&cache108,&cache109,&cache110,&cache111,&cache112,&cache113,&cache114,&cache115,&cache116,&cache117,&cache118,&cache119,&cache120,&cache121,&cache122,&cache123,&cache124,&cache125,&cache126,&cache127,&cache128,&cache129,&cache130,&cache131,&cache132,&cache133,&cache134,&cache135,&cache136,&cache137,&cache138,&cache139,&cache140,&cache141,&cache142,&cache143,&cache144,&cache145,&cache146,&cache147,&cache148,&cache149,&cache150,&cache151,&cache152,&cache153,&cache154,&cache155,&cache156,&cache157,&cache158,&cache159,&cache160,&cache161,&cache162,&cache163,&cache164,&cache165,&cache166,&cache167,&cache168,&cache169,&cache170,&cache171,&cache172,&cache173,&cache174,&cache175,&cache176,&cache177,&cache178,&cache179,&cache180,&cache181,&cache182,&cache183,&cache184,&cache185,&cache186,&cache187,&cache188,&cache189,&cache190,&cache191,&cache192,&cache193,&cache194,&cache195,&cache196,&cache197,&cache198,&cache199,&cache200,&cache201,&cache202,&cache203,&cache204,&cache205,&cache206,&cache207,&cache208,&cache209,&cache210,&cache211,&cache212,&cache213,&cache214,&cache215,&cache216,&cache217,&cache218,&cache219,&cache220,&cache221,&cache222,&cache223,&cache224,&cache225,&cache226,&cache227,&cache228,&cache229,&cache230,&cache231,&cache232,&cache233,&cache234,&cache235,&cache236,&cache237,&cache238,&cache239,&cache240,&cache241,&cache242,&cache243,&cache244,&cache245,&cache246,&cache247,&cache248,&cache249,&cache250,&cache251,&cache252,&cache253,&cache254,&cache255,&cache256,&cache257,&cache258,&cache259,&cache260,&cache261,&cache262,&cache263,&cache264,&cache265,&cache266,&cache267,&cache268,&cache269,&cache270,&cache271,&cache272,&cache273,&cache274,&cache275,&cache276,&cache277,&cache278,&cache279,&cache280,&cache281,&cache282,&cache283,&cache284,&cache285,&cache286,&cache287,&cache288,&cache289,&cache290,&cache291,&cache292,&cache293,&cache294,&cache295,&cache296,&cache297,&cache298,&cache299,&cache300,&cache301,&cache302,&cache303,&cache304,&cache305,&cache306,&cache307,&cache308,&cache309,&cache310,&cache311,&cache312,&cache313,&cache314,&cache315,&cache316,&cache317,&cache318,&cache319,&cache320,&cache321,&cache322,&cache323,&cache324,&cache325,&cache326,&cache327,&cache328,&cache329,&cache330,&cache331,&cache332,&cache333,&cache334,&cache335,&cache336,&cache337,&cache338,&cache339,&cache340,&cache341,&cache342,&cache343,&cache344,&cache345,&cache346,&cache347,&cache348,&cache349,&cache350,&cache351,&cache352,&cache353,&cache354,&cache355,&cache356,&cache357,&cache358,&cache359,&cache360,&cache361,&cache362,&cache363,&cache364,&cache365,&cache366,&cache367,&cache368,&cache369,&cache370,&cache371,&cache372,&cache373,&cache374,&cache375,&cache376,&cache377,&cache378,&cache379,&cache380,&cache381,&cache382,&cache383,&cache384,&cache385,&cache386,&cache387,&cache388,&cache389,&cache390,&cache391,&cache392,&cache393,&cache394,&cache395,&cache396,&cache397,&cache398,&cache399,&cache400,&cache401,&cache402,&cache403,&cache404,&cache405,&cache406,&cache407,&cache408,&cache409,&cache410,&cache411,&cache412,&cache413,&cache414,&cache415,&cache416,&cache417,&cache418,&cache419,&cache420,&cache421,&cache422,&cache423,&cache424,&cache425,&cache426,&cache427,&cache428,&cache429,&cache430,&cache431,&cache432,&cache433,&cache434,&cache435,&cache436,&cache437,&cache438,&cache439,&cache440,&cache441,&cache442,&cache443,&cache444,&cache445,&cache446,&cache447,&cache448,&cache449,&cache450,&cache451,&cache452,&cache453,&cache454,&cache455,&cache456,&cache457,&cache458,&cache459,&cache460,&cache461,&cache462,&cache463,&cache464,&cache465,&cache466,&cache467,&cache468,&cache469,&cache470,&cache471,&cache472,&cache473,&cache474,&cache475,&cache476,&cache477,&cache478,&cache479,&cache480,&cache481,&cache482,&cache483,&cache484,&cache485,&cache486,&cache487,&cache488,&cache489,&cache490,&cache491,&cache492,&cache493,&cache494,&cache495,&cache496,&cache497,&cache498,&cache499,&cache500,&cache501,&cache502,&cache503,&cache504,&cache505,&cache506,&cache507,&cache508,&cache509,&cache510,&cache511};
#pragma GCC target("avx2,bmi,bmi2,movbe")
void root_copy24_parent(unsigned n,char*out){if(n!=24)__builtin_trap();for(unsigned b=0;b<512;++b){const char*s=(const char*)blocks[b];char*d=out+4096*b;unsigned i=0;for(;i<4096&&((uintptr_t)(d+i)&31);++i)d[i]=s[i];for(;i+256<=4096;i+=256){asm volatile(
"vmovdqu 0(%0),%%ymm0\n\tvmovntdq %%ymm0,0(%1)\n\tvmovdqu 32(%0),%%ymm0\n\tvmovntdq %%ymm0,32(%1)\n\tvmovdqu 64(%0),%%ymm0\n\tvmovntdq %%ymm0,64(%1)\n\tvmovdqu 96(%0),%%ymm0\n\tvmovntdq %%ymm0,96(%1)\n\tvmovdqu 128(%0),%%ymm0\n\tvmovntdq %%ymm0,128(%1)\n\tvmovdqu 160(%0),%%ymm0\n\tvmovntdq %%ymm0,160(%1)\n\tvmovdqu 192(%0),%%ymm0\n\tvmovntdq %%ymm0,192(%1)\n\tvmovdqu 224(%0),%%ymm0\n\tvmovntdq %%ymm0,224(%1)"::"r"(s+i),"r"(d+i):"memory","ymm0");}
for(;i+32<=4096;i+=32)asm volatile("vmovdqu (%0),%%ymm0;vmovntdq %%ymm0,(%1)"::"r"(s+i),"r"(d+i):"memory","ymm0");for(;i<4096;++i)d[i]=s[i];}asm volatile("sfence":::"memory");}
void debruijn(unsigned n,char*out){if(n!=24)__builtin_trap();if((uintptr_t)out&31){root_copy24_parent(n,out);return;}
for(unsigned b=0;b<512;++b){const char*s=(const char*)blocks[b];char*d=out+4096*b;
for(unsigned i=0;i<4096;i+=1024)asm volatile("vmovdqu 0(%0),%%ymm0\n\tvmovntdq %%ymm0,0(%1)\n\tvmovdqu 32(%0),%%ymm0\n\tvmovntdq %%ymm0,32(%1)\n\tvmovdqu 64(%0),%%ymm0\n\tvmovntdq %%ymm0,64(%1)\n\tvmovdqu 96(%0),%%ymm0\n\tvmovntdq %%ymm0,96(%1)\n\tvmovdqu 128(%0),%%ymm0\n\tvmovntdq %%ymm0,128(%1)\n\tvmovdqu 160(%0),%%ymm0\n\tvmovntdq %%ymm0,160(%1)\n\tvmovdqu 192(%0),%%ymm0\n\tvmovntdq %%ymm0,192(%1)\n\tvmovdqu 224(%0),%%ymm0\n\tvmovntdq %%ymm0,224(%1)\n\tvmovdqu 256(%0),%%ymm0\n\tvmovntdq %%ymm0,256(%1)\n\tvmovdqu 288(%0),%%ymm0\n\tvmovntdq %%ymm0,288(%1)\n\tvmovdqu 320(%0),%%ymm0\n\tvmovntdq %%ymm0,320(%1)\n\tvmovdqu 352(%0),%%ymm0\n\tvmovntdq %%ymm0,352(%1)\n\tvmovdqu 384(%0),%%ymm0\n\tvmovntdq %%ymm0,384(%1)\n\tvmovdqu 416(%0),%%ymm0\n\tvmovntdq %%ymm0,416(%1)\n\tvmovdqu 448(%0),%%ymm0\n\tvmovntdq %%ymm0,448(%1)\n\tvmovdqu 480(%0),%%ymm0\n\tvmovntdq %%ymm0,480(%1)\n\tvmovdqu 512(%0),%%ymm0\n\tvmovntdq %%ymm0,512(%1)\n\tvmovdqu 544(%0),%%ymm0\n\tvmovntdq %%ymm0,544(%1)\n\tvmovdqu 576(%0),%%ymm0\n\tvmovntdq %%ymm0,576(%1)\n\tvmovdqu 608(%0),%%ymm0\n\tvmovntdq %%ymm0,608(%1)\n\tvmovdqu 640(%0),%%ymm0\n\tvmovntdq %%ymm0,640(%1)\n\tvmovdqu 672(%0),%%ymm0\n\tvmovntdq %%ymm0,672(%1)\n\tvmovdqu 704(%0),%%ymm0\n\tvmovntdq %%ymm0,704(%1)\n\tvmovdqu 736(%0),%%ymm0\n\tvmovntdq %%ymm0,736(%1)\n\tvmovdqu 768(%0),%%ymm0\n\tvmovntdq %%ymm0,768(%1)\n\tvmovdqu 800(%0),%%ymm0\n\tvmovntdq %%ymm0,800(%1)\n\tvmovdqu 832(%0),%%ymm0\n\tvmovntdq %%ymm0,832(%1)\n\tvmovdqu 864(%0),%%ymm0\n\tvmovntdq %%ymm0,864(%1)\n\tvmovdqu 896(%0),%%ymm0\n\tvmovntdq %%ymm0,896(%1)\n\tvmovdqu 928(%0),%%ymm0\n\tvmovntdq %%ymm0,928(%1)\n\tvmovdqu 960(%0),%%ymm0\n\tvmovntdq %%ymm0,960(%1)\n\tvmovdqu 992(%0),%%ymm0\n\tvmovntdq %%ymm0,992(%1)"::"r"(s+i),"r"(d+i):"memory","ymm0");}
asm volatile("sfence":::"memory");}
| Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
| Testcase #1 | 365.54 us | 2 MB + 8 KB | Accepted | Score: 100 | 显示更多 |