{"id":188,"date":"2019-09-01T16:58:14","date_gmt":"2019-09-01T08:58:14","guid":{"rendered":"http:\/\/blog.coolcoding.cn\/?p=188"},"modified":"2019-09-01T16:58:14","modified_gmt":"2019-09-01T08:58:14","slug":"%e8%af%be%e5%a0%82%e4%bd%9c%e4%b8%9a-n%e7%9a%87%e5%90%8e%e7%ae%97%e6%b3%95","status":"publish","type":"post","link":"https:\/\/blog.coolcoding.cn\/?p=188","title":{"rendered":"\u8bfe\u5802\u4f5c\u4e1a-N\u7687\u540e\u7b97\u6cd5"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h>\n#include &lt;tchar.h>\n#include &lt;vector>\n#include &lt;stack>\n#include &lt;string>\n#include &lt;algorithm>\n#include &lt;windows.h>\n#include \"mmsystem.h\"\n#pragma comment(lib, \"winmm.lib\")\n \nclass ntbase\n{\npublic:\n\tstatic const char* tostr(int i)\n\t{\n\t\tstatic char buff[32];\n\t\tsprintf_s(buff, \"%d\", i);\n\t\treturn buff;\n\t}\n \n\tstatic const char* tostr(unsigned int i)\n\t{\n\t\tstatic char buff[32];\n\t\tsprintf_s(buff, \"%d\", i);\n\t\treturn buff;\n\t}\n \n\tstatic const char* tostr2d(unsigned int i)\n\t{\n\t\tstatic char buff[32];\n\t\tsprintf_s(buff, \"%02d\", i);\n\t\treturn buff;\n\t}\n};\ntemplate&lt;typename T>\nstruct ntpos_t\n{\n\tntpos_t(T a, T b):x(a), y(b) {}\n\tntpos_t():x(0), y(0) {}\n\tT x, y;\n};\n \ntypedef ntpos_t&lt;unsigned int> ntpos_ui;\ntypedef std::vector&lt;ntpos_ui> ntpos_v1;\ntypedef std::vector&lt;ntpos_v1> ntpos_v2;\n \n \nenum { FORCE_DIR= 4 };\n \ntemplate&lt;unsigned int SIZE>\nstruct ntpos_stack_uz\n{\n\tntpos_stack_uz() \n\t: usize(0)\n\t, log_enable(false) \n\t{\n \n\t}\n \n\tntpos_ui pos[SIZE];\n\tunsigned int usize;\n \n\tvoid push(unsigned int ax, unsigned int ay)\n\t{\n\t\tpos[usize].x = ax;\n\t\tpos[usize].y = ay;\n\t\t++usize;\n \n\t\tif (log_enable)\n\t\t{\n\t\t\tfor(unsigned int i=0; i&lt;usize-1; ++i)\n\t\t\t{\n\t\t\t\tlog_content+= \"  \";\n\t\t\t}\n\t\t\tchar buff[256];\n\t\t\tsprintf_s(buff, \">%d,%d\\n\", ax, ay);\n\t\t\tlog_content += buff;\n\t\t}\n\t}\n \n\tvoid pop()\n\t{\n\t\tif (usize> 0)\n\t\t{\n\t\t\t--usize;\n \n\t\t\tif (log_enable)\n\t\t\t{\n\t\t\t\tfor(unsigned int i=0; i&lt;usize; ++i)\n\t\t\t\t{\n\t\t\t\t\tlog_content+= \"  \";\n\t\t\t\t}\n\t\t\t\tchar buff[256];\n\t\t\t\tsprintf_s(buff, \"&lt;%d,%d\\n\", pos[usize].x, pos[usize].y);\n\t\t\t\tlog_content += buff;\n\t\t\t}\n\t\t}\n\t}\n \n\tunsigned int size() const \n\t{\n\t\treturn usize;\n\t}\n \n\tbool log_enable;\n\tstd::string log_content;\n};\n \ntemplate&lt;unsigned int D1SIZE>\nstruct flag_1d\n{\n\tflag_1d(): size(0) {}\n\tntpos_ui pos[D1SIZE];\n\tunsigned int size;\n \n\tvoid add(unsigned int x, unsigned int y)\n\t{\n\t\tpos[size].x = x;\n\t\tpos[size].y = y;\n\t\t++size;\n\t}\n};\n \ntemplate&lt;unsigned int D1SIZE, unsigned int D2SIZE>\nstruct flag_2d\n{\n\tflag_1d&lt;D1SIZE> lines[D2SIZE];\n \n\tenum { SIZE = D2SIZE };\n \n\tvoid clear()\n\t{\n\t\tfor(unsigned int i=0; i&lt;D2SIZE; ++i)\n\t\t{\n\t\t\tlines[i].size = 0;\n\t\t}\n\t}\n};\n \ntemplate &lt;unsigned int BOUND_SIZE>\nstruct influence_range\n{\n\tinfluence_range()\n\t{\n\t\tmemset(this, 0, sizeof(*this));\n\t}\n \n\ttypedef flag_2d&lt;BOUND_SIZE, FORCE_DIR> force_flag_2d;\n\tforce_flag_2d inf_range[BOUND_SIZE][BOUND_SIZE];\n};\n \ntemplate &lt;unsigned int BOUND_SIZE>\nstruct force_range\n{\n\tforce_range()\n\t{\n\t\tmemset(this, 0, sizeof(*this));\n\t}\n \n\tvoid add_force(unsigned int y, unsigned int x)\n\t{\n\t\t++force[y][x];\n\t}\n \n\tvoid dec_force(unsigned int y, unsigned int x)\n\t{\n\t\t--force[y][x];\n\t}\n \n\tint at(unsigned int y, unsigned int x) const \n\t{\n\t\treturn force[y][x];\n\t}\n \n\tint is_empty(unsigned int y, unsigned int x) const \n\t{\n\t\treturn at(y, x) == 0;\n\t}\n \n\tint force[BOUND_SIZE][BOUND_SIZE];\n};\n \nstruct force_obj\n{\n\tforce_obj(unsigned int acod, unsigned int maxy): cod(acod), max_y(maxy) {}\n\tunsigned int cod;\n\tunsigned int max_y;\n};\n \ntypedef std::vector&lt;force_obj> force_objs;\n \ninline bool operator &lt; ( const force_obj&amp; a, const force_obj&amp; b)\n{\n\treturn a.max_y &lt; b.max_y;\n}\n \ntemplate&lt;typename QUEEN_OBJECT, unsigned int A_BOUND_SIZE>\nstruct ntqueen \n{\n\tenum { BOUND_SIZE=A_BOUND_SIZE };\n\ttypedef ntpos_stack_uz&lt;BOUND_SIZE> queen_stack;\n\ttypedef flag_2d&lt;BOUND_SIZE, FORCE_DIR> force_flag_2d;\n\ttypedef flag_1d&lt;BOUND_SIZE> force_flag_1d;\n\ttypedef force_range&lt;BOUND_SIZE> queen_range;\n\ttypedef influence_range&lt;BOUND_SIZE> queen_inf_range;\n\ttypedef QUEEN_OBJECT bound_t[BOUND_SIZE][BOUND_SIZE];\n \n\tbound_t bound;\n\tqueen_inf_range influences;\n \n\tntqueen()\n\t{\n\t\tmemset(this, 0, sizeof(*this));\n\t\t_build_influences(influences);\n\t}\n \n\tvoid _build_inf_ele(unsigned int x, unsigned int y, force_flag_2d&amp; out) const\n\t{\n\t\tunsigned int idx= 0;\n \n\t\tout.clear();\n \n\t\tfor(int ax=0; ax&lt;BOUND_SIZE; ++ax)\n\t\t{\n\t\t\tif (ax != x)\n\t\t\t{\n\t\t\t\tout.lines[idx].add(ax, y);\n\t\t\t}\n\t\t}\n \n\t\t++idx;\n\t\tfor(int ay=0; ay&lt;BOUND_SIZE; ++ay)\n\t\t{\n\t\t\tif (ay!= y)\n\t\t\t{\n\t\t\t\tout.lines[idx].add(x, ay);\n\t\t\t}\n\t\t}\n \n\t\t++idx;\n\t\tfor(int ax=x+1, ay=y+1; ax&lt;BOUND_SIZE &amp;&amp; ay&lt;BOUND_SIZE; ++ax, ++ay)\n\t\t{\n\t\t\tout.lines[idx].add(ax, ay);\n\t\t}\n\t\tfor(int ax=x+1, ay=y-1; ax&lt;BOUND_SIZE &amp;&amp; ay>=0; ++ax, --ay)\n\t\t{\n\t\t\tout.lines[idx].add(ax, ay);\n\t\t}\n \n\t\t++idx;\n\t\tfor(int ax=x-1, ay=y+1; ax>=0 &amp;&amp; ay&lt;BOUND_SIZE; --ax, ++ay)\n\t\t{\n\t\t\tout.lines[idx].add(ax, ay);\n\t\t}\n\t\tfor(int ax=x-1, ay=y-1; ax>=0 &amp;&amp; ay>=0; --ax, --ay)\n\t\t{\n\t\t\tout.lines[idx].add(ax, ay);\n\t\t}\n\t}\n \n\tvoid _build_influences(queen_inf_range&amp; infrange)\n\t{\n\t\tfor(unsigned int y=0; y&lt;BOUND_SIZE; ++y)\n\t\t{\n\t\t\tfor(unsigned int x=0; x&lt;BOUND_SIZE; ++x)\n\t\t\t{\n\t\t\t\t_build_inf_ele(x, y, infrange.inf_range[y][x]);\n\t\t\t}\n\t\t}\n\t}\n \n\tconst force_flag_2d&amp; get_influence(unsigned int y, unsigned int x) const\n\t{\n\t\treturn influences.inf_range[y][x];\n\t}\n\t\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n \n\tbool layout_unique_v3(queen_stack&amp; tk, queen_range&amp; record, int sy=0)\n\t{\n\t\tsize_t size = tk.size();\n\t\tfor(unsigned int y=sy; y&lt;BOUND_SIZE; ++y)\n\t\t{\n\t\t\tforce_objs objs;\n\t\t\tobjs.reserve(BOUND_SIZE);\n \n\t\t\tfor(unsigned int x=0; x&lt;BOUND_SIZE; ++x)\n\t\t\t{\n\t\t\t\tif (!record.is_empty(y, x))\n\t\t\t\t{\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n \n\t\t\t\tif (! put_test(y, x))\n\t\t\t\t{\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n \n\t\t\t\tconst force_flag_2d&amp; flag2d= get_influence(y, x);\n\t\t\t\tunsigned int num= get_max_line(flag2d);\n\t\t\t\tobjs.push_back(force_obj(x, num));\n\t\t\t}\n \n\t\t\tif (objs.empty())\n\t\t\t{\n\t\t\t\tcontinue;\n\t\t\t}\n \n\t\t\tstd::sort(objs.begin(), objs.end());\n \n\t\t\tfor(unsigned int i=0; i&lt;objs.size(); ++i)\n\t\t\t{\n\t\t\t\tunsigned int x = objs[i].cod;\n \n\t\t\t\ttk.push(x, y);\n\t\t\t\tset(y, x, create_entity());\n\t\t\t\tadd_force_to_range(y, x, record);\n \n\t\t\t\tif ( tk.size() == BOUND_SIZE)\n\t\t\t\t{\n\t\t\t\t\treturn true;\n\t\t\t\t}\n \n\t\t\t\tif (!layout_unique_v3(tk, record, sy+1))\n\t\t\t\t{\n\t\t\t\t\tset(y, x, create_empty());\n\t\t\t\t\ttk.pop();\n\t\t\t\t\tdec_force_to_range(y, x, record);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif ( tk.size() == BOUND_SIZE)\n\t\t\t\t\t{\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n \n\t\treturn tk.size() > size;\n\t}\n \n\tqueen_stack layout_queen_v3()\n\t{\n\t\tqueen_stack r;\n\t\t\/\/r.log_enable= true;\n\t\tqueen_range record;\n\t\tlayout_unique_v3(r, record);\n\t\treturn r;\n\t}\n \n\t\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n \n\tvoid add_force_to_range(unsigned int y, unsigned int x, queen_range&amp; record)\n\t{\n\t\tconst force_flag_2d&amp; out= get_influence(y, x);\n\t\tfor(unsigned int i=0; i&lt;out.SIZE; ++i)\n\t\t{\n\t\t\tfor(unsigned int j=0; j&lt;out.lines[i].size; ++j)\n\t\t\t{\n\t\t\t\tconst ntpos_ui&amp; pos= out.lines[i].pos[j];\n\t\t\t\trecord.add_force(pos.y, pos.x);\n\t\t\t}\n\t\t}\n\t\trecord.add_force(y, x);\n\t}\n \n\tvoid dec_force_to_range(unsigned int y, unsigned int x, queen_range&amp; record)\n\t{\n\t\tconst force_flag_2d&amp; out= get_influence(y, x);\n\t\tfor(unsigned int i=0; i&lt;out.SIZE; ++i)\n\t\t{\n\t\t\tfor(unsigned int j=0; j&lt;out.lines[i].size; ++j)\n\t\t\t{\n\t\t\t\tconst ntpos_ui&amp; pos= out.lines[i].pos[j];\n\t\t\t\trecord.dec_force(pos.y, pos.x);\n\t\t\t}\n\t\t}\n\t\trecord.dec_force(y, x);\n\t}\n \n\tbool layout_unique_v2(queen_stack&amp; tk, queen_range&amp; record)\n\t{\n\t\tsize_t size = tk.size();\n\t\tfor(unsigned int y=0; y&lt;BOUND_SIZE; ++y)\n\t\t{\n\t\t\tfor(unsigned int x=0; x&lt;BOUND_SIZE; ++x)\n\t\t\t{\n\t\t\t\tif (!record.is_empty(y, x))\n\t\t\t\t{\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n \n\t\t\t\tif (! put_test(y, x))\n\t\t\t\t{\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n \n\t\t\t\ttk.push(x, y);\n\t\t\t\tset(y, x, create_entity());\n\t\t\t\tadd_force_to_range(y, x, record);\n \n\t\t\t\tif ( tk.size() == BOUND_SIZE)\n\t\t\t\t{\n\t\t\t\t\treturn true;\n\t\t\t\t}\n \n\t\t\t\tif (!layout_unique_v2(tk, record))\n\t\t\t\t{\n\t\t\t\t\tset(y, x, create_empty());\n\t\t\t\t\ttk.pop();\n\t\t\t\t\tdec_force_to_range(y, x, record);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif ( tk.size() == BOUND_SIZE)\n\t\t\t\t\t{\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n \n\t\treturn tk.size() > size;\n\t}\n \n\tqueen_stack layout_queen_v2()\n\t{\n\t\tqueen_stack r;\n\t\tqueen_range record;\n\t\tlayout_unique_v2(r, record);\n\t\treturn r;\n\t}\n \n\t\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n \n\tbool layout_unique_v1(queen_stack&amp; tk)\n\t{\n\t\tsize_t size = tk.size();\n\t\tfor(unsigned int y=0; y&lt;BOUND_SIZE; ++y)\n\t\t{\n\t\t\tfor(unsigned int x=0; x&lt;BOUND_SIZE; ++x)\n\t\t\t{\n\t\t\t\tif (! put_test(y, x))\n\t\t\t\t{\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n \n\t\t\t\ttk.push(x, y);\n\t\t\t\tset(y, x, create_entity());\n \n\t\t\t\tif ( tk.size() == BOUND_SIZE)\n\t\t\t\t{\n\t\t\t\t\treturn true;\n\t\t\t\t}\n \n\t\t\t\tif (!layout_unique_v1(tk))\n\t\t\t\t{\n\t\t\t\t\tset(y, x, create_empty());\n\t\t\t\t\ttk.pop();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n \n\t\treturn tk.size() > size;\n\t}\n \n\tqueen_stack layout_queen_v1()\n\t{\n\t\tqueen_stack r;\n\t\tlayout_unique_v1(r);\n\t\treturn r;\n\t}\n \n\tbool put_test(unsigned int y, unsigned int x) const\n\t{\n\t\tif (!is_empty_pos(y, x))\n\t\t{\n\t\t\treturn false;\n\t\t}\n \n\t\tif (!is_valid())\n\t\t{\n\t\t\treturn false;\n\t\t}\n \n\t\tntqueen&lt;QUEEN_OBJECT, BOUND_SIZE> obj(*this);\n\t\tobj.set(y, x, create_entity() );\n\t\treturn obj.is_valid();\n\t}\n \n\t\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n \n\tbool is_emtpy_element(const QUEEN_OBJECT&amp; v) const\n\t{\n\t\treturn v.is_empty();\n\t}\n \n\tQUEEN_OBJECT create_entity() const\n\t{\n\t\treturn QUEEN_OBJECT::create_entity();\n\t}\n \n\tQUEEN_OBJECT create_empty() const \n\t{\n\t\treturn QUEEN_OBJECT::create_empty();\n\t}\n \n\t\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n \n\tvoid print_element(const QUEEN_OBJECT&amp; v)\n\t{\n\t\tprintf(\"%d\", v);\n\t}\n \n\tvoid _sprint_element(std::string&amp; str, const QUEEN_OBJECT&amp; v)\n\t{\n\t\tstr += v.to_str();\n\t}\n \n\tbool is_empty_pos(unsigned int y, unsigned int x) const\n\t{\n\t\treturn is_emtpy_element( get(y, x) );\n\t}\n \n\tunsigned int get_max_line(const force_flag_2d&amp; lineobj) const\n\t{\n\t\tunsigned int max_y = 0;\n\t\tfor( unsigned int i=2; i&lt;FORCE_DIR; ++i)\n\t\t{\n\t\t\tconst force_flag_1d&amp; d1 = lineobj.lines[i];\n\t\t\tfor(unsigned int j= 0; j&lt;d1.size; ++j)\n\t\t\t{\n\t\t\t\tif (max_y &lt; d1.pos[j].y)\n\t\t\t\t{\n\t\t\t\t\tmax_y = d1.pos[j].y;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn max_y;\n\t}\n \n\tunsigned int counter_force(const force_flag_2d&amp; lineobj) const\n\t{\n\t\tunsigned int f= 0;\n\t\tfor( unsigned int i=0; i&lt;FORCE_DIR; ++i)\n\t\t{\n\t\t\tconst force_flag_1d&amp; curr= lineobj.lines[i];\n \n\t\t\tfor(unsigned int j=0; j&lt;curr.size; ++j)\n\t\t\t{\n\t\t\t\tif (!is_empty_pos(curr.pos[j].y, curr.pos[j].x))\n\t\t\t\t{\n\t\t\t\t\t++f;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n \n\t\treturn f;\n\t}\n \n\tbool is_valid() const\n\t{\n\t\tfor(unsigned int y= 0; y&lt; BOUND_SIZE; ++y)\n\t\t{\n\t\t\tfor(unsigned int x=0; x&lt; BOUND_SIZE; ++x)\n\t\t\t{\n\t\t\t\tif (is_empty_pos(y, x))\n\t\t\t\t{\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n \n\t\t\t\tconst force_flag_2d&amp; out= get_influence(y, x);\n\t\t\t\tif (counter_force(out) > 0)\n\t\t\t\t{\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n \n\tconst QUEEN_OBJECT&amp; get(unsigned int y, unsigned int x) const\n\t{\n\t\treturn bound[y][x];\n\t}\n \n\tvoid set(unsigned int y, unsigned int x, const QUEEN_OBJECT&amp; v)\n\t{\n\t\tbound[y][x]= v;\n\t}\n \n\tvoid _sprint_head(std::string&amp; str)\n\t{\n\t\tstr += \"    \";\n \n\t\tfor(unsigned int i=0; i&lt;BOUND_SIZE; ++i)\n\t\t{\n\t\t\tstr+= ntbase::tostr(i);\n\t\t\tstr+= \" \";\n\t\t}\n \n\t\tstr += \"\\n  \u250c\";\n \n\t\tfor(unsigned int i=0; i&lt;BOUND_SIZE; ++i)\n\t\t{\n\t\t\tstr+= \"\u2500\";\n\t\t}\n \n\t\tstr += \"\u2510\\n\";\n\t}\n \n\tvoid _sprint_cont(std::string&amp; str)\n\t{\n\t\tfor(unsigned int y=0; y&lt;BOUND_SIZE; ++y)\n\t\t{\n\t\t\tstr += ntbase::tostr2d(y);\n\t\t\tstr += \"\u2502\";\n \n\t\t\tfor(unsigned int x=0; x&lt;BOUND_SIZE; ++x)\n\t\t\t{\n\t\t\t\tconst QUEEN_OBJECT&amp; element= get(y, x);\n\t\t\t\t_sprint_element(str, element);\n\t\t\t\tstr += \" \";\n\t\t\t}\n \n\t\t\tstr += \"\u2502\\n\";\n\t\t}\n\t}\n \n\tvoid _sprint_end(std::string&amp; str)\n\t{\n\t\tstr += \"  \u2514\";\n \n\t\tfor(unsigned int i=0; i&lt;BOUND_SIZE; ++i)\n\t\t{\n\t\t\tstr+= \"\u2500\";\n\t\t}\n \n\t\tstr += \"\u2518\\n\";\n\t}\n \n\tvoid view()\n\t{\n\t\tstd::string str;\n\t\t_sprint_head(str);\n\t\t_sprint_cont(str);\n\t\t_sprint_end(str);\n\t\tprintf(str.c_str());\n\t}\n};\n \nstruct chess_piece\n{\n\tenum \n\t{\n\t\tEMPTY = 0,\n\t\tENTITY= 1,\n\t};\n \n\tint piece_data;\n \n\tchess_piece(): piece_data(EMPTY) {}\n\tchess_piece(int d): piece_data(d) {}\n \n\tbool is_empty() const { return piece_data== EMPTY; }\n \n\tbool operator == ( const chess_piece&amp; obj) \n\t{\n\t\treturn obj.piece_data == piece_data;\n\t}\n \n\tconst char* to_str() const\n\t{\n\t\treturn ntbase::tostr(piece_data);\n\t}\n \n\tstatic chess_piece create_empty() \n\t{ \n\t\treturn chess_piece(EMPTY);\n\t}\n \n\tstatic chess_piece create_entity()\n\t{\n\t\treturn chess_piece(ENTITY);\n\t}\n};\n \n \nint main(int argc, _TCHAR* argv[])\n{\n \n\tunsigned long t2= timeGetTime();\n \n\ttypedef ntqueen&lt;chess_piece, 8> queen11;\n\tqueen11 obj; \n\tqueen11::queen_stack k= obj.layout_queen_v3(); \n\tobj.view();\n \n\tunsigned long t3= timeGetTime();\n \n\tprintf(k.log_content.c_str());\n \n\tprintf(\"%d\\n\", t3-t2);\n \n \n\treturn 0;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts\/188"}],"collection":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=188"}],"version-history":[{"count":1,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts\/188\/revisions"}],"predecessor-version":[{"id":189,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts\/188\/revisions\/189"}],"wp:attachment":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=188"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=188"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=188"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}