Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
共享代码. 小范围内的查表, 大范围接近小范围, 0MS#include<stdio.h> #define maxn 12 #define max_distance 3 static const char * dfs1[1] = { "#", }; static const char * dfs2[4] = { "##", "##", "#", "#", }; static const char * dfs3[9] = { "&8$6G", ">@%0,", "8$&H5", "#J6", "###", "G$8", "&5", ">>", "8#", }; static const char * dfs4[16] = { "&:B.6JR@", ">@86.088", "8&.@H6@@", "R>6JB.8:", "&8@.6J", ">@86.0", "8&.@H6", "@>68B.", "&8@.", ">@J6", "8&.B", "@>68", "&:", ">@", "8&", "R>", }; static const char * dfs5[25] = { "&88H86J88888G", ">@@@..0@@@@@>", "8&686H6J88885", "@>@.@B..@@@@>", "88&6J8H888J85", "&88686J888", ">@@@..0@@@", "8&686H6J88", "@>@.@B..@@", "88&688H888", "&88686J5", ">@@@..0>", "8&686H6G", "@>@.@B.,", "88&688H5", "&8868", ">@B@.", "8&686", "@>@.B", "88&68", "&85", ">@>", "8&5", "@>>", "88#", }; static const char * dfs6[36] = { "&88B.B6J8@@B88JBBB", ">@@868.0@888@@BJJJ", "8&8.@.H6J@@@888BBB", "@>@686B.0888@@@JJJ", "88&@.@8H6@@@J88BBB", "@@>J6J@B.J88B@@JJJ", "&88@.B6J8@@B88J", ">@@868.0@888@@B", "8&8.@.H6J@@@888", "@>@686B.0888@@@", "88&@.@8H6@@@J88", "@@>J68@B.J88B@@", "&88@.B6J8@@B", ">@@868.0@888", "8&8.@.H6J@@@", "@>@686B.0888", "88&@.@8H6@@@", "@@>J68@B.J88", "&88@.B6J8", ">@@868.0@", "8&8.@.H6J", "@>@686B.0", "88&@.@8H6", "@@>J68@B.", "&88@.B", ">@@J68", "8&8.@.", "@>@686", "88&@.B", "@@>J68", "&88", ">@@", "8&8", "@>@", "88&", "@@>", }; static const char * dfs7[49] = { "&88JH8J6J8J88J88JJJJLJJLG", ">@@@@.B.0@@@@B@@BBBBBBBBP", "8&86868H6J8888888JJJJJJJG", "@>@@.@.B.0@@@@@@@BBBBBBB>", "88&86868H6J888J888JJJJJJG", "@@>B@.@@B.0@@@B@@BBBBTBB>", "J88&J6JJ8H8J88JJ8:JJJLJJG", "&88J68J6J8J88J88JJJJL", ">@@@@.B.0@@@@B@@BBBBB", "8&86868H6J8888888JJJJ", "@>@@.@.B.0@@@@@@@BBBB", "88&86868H6J888J888JJJ", "@@>B@.@@B.0@@@B@@BBBB", "J88&J68J8H8J88JJ8:JJJ", "&88J68J6J8J88J88JG", ">@@@@.B.0@@@@B@@B>", "8&86868H6J8888888G", "@>@@.@.B.0@@@@@@@>", "88&86868H6J888J885", "@@>B@.@@B.0@@@B@@>", "J88&J68J8H8J88JJ85", "&88J68J6J8J88J", ">@@@@.B.0@@@@B", "8&86868H6J8888", "@>@@.@.B.0@@@@", "88&86868H6J888", "@@>B@.@@B.0@@@", "J88&J68J8H8J88", "&88J68J6J8G", ">@@@@.B.0@>", "8&86868H6J5", "@>@@.@.B.0>", "88&86868H6G", "@@>B@.@@B.,", "J88&J68J8H5", "&88J68J", ">@@B@.B", "8&86868", "@>@@.@.", "88&8686", "@@>B@.B", "J88&J68", "&88G", ">@@>", "8&85", "@>@>", "88&5", "@@>>", "J88#", }; static const char * dfs8[64] = { "&88LB.BB6J8L@@BB88JLBBBTJJLLTTTV", ">@@B868J.0@B888J@@BBJJJLBBBTLLLL", "8&88.@.BH6J8@@@B888JBBBBJJJLTTTT", "@>@@6868B.0@8888@@@BJJJJBBBBLLLL", "88&8@.@.8H6J@@@@J888BBBBJJJJTTTT", "@@>@J686@B.0J888B@@@JJJJTBBBLLLL", "J88&B@.@J8H6B@@@JJ88TBBBLJJJTTTT", "T@@>JJ6JT@B.JJ88TB@@LJJJTTBB^LLL", "&88L@.BB6J8L@@BB88JLBBBTJJLL", ">@@B868J.0@B888J@@BBJJJLBBBT", "8&88.@.BH6J8@@@B888JBBBBJJJL", "@>@@6868B.0@8888@@@BJJJJBBBB", "88&8@.@.8H6J@@@@J888BBBBJJJJ", "@@>@J686@B.0J888B@@@JJJJTBBB", "J88&B@.@J8H6B@@@JJ88TBBBLJJJ", "T@@>JJ68T@B.JJ88TB@@LJJJTTBB", "&88L@.BB6J8L@@BB88JLBBBT", ">@@B868J.0@B888J@@BBJJJL", "8&88.@.BH6J8@@@B888JBBBB", "@>@@6868B.0@8888@@@BJJJJ", "88&8@.@.8H6J@@@@J888BBBB", "@@>@J686@B.0J888B@@@JJJJ", "J88&B@.@J8H6B@@@JJ88TBBB", "T@@>JJ68T@B.JJ88TB@@LJJJ", "&88L@.BB6J8L@@BB88JL", ">@@B868J.0@B888J@@BB", "8&88.@.BH6J8@@@B888J", "@>@@6868B.0@8888@@@B", "88&8@.@.8H6J@@@@J888", "@@>@J686@B.0J888B@@@", "J88&B@.@J8H6B@@@JJ88", "T@@>JJ68T@B.JJ88TB@@", "&88L@.BB6J8L@@BB", ">@@B868J.0@B888J", "8&88.@.BH6J8@@@B", "@>@@6868B.0@8888", "88&8@.@.8H6J@@@@", "@@>@J686@B.0J888", "J88&B@.@J8H6B@@@", "T@@>JJ68T@B.JJ88", "&88L@.BB6J8L", ">@@B868J.0@B", "8&88.@.BH6J8", "@>@@6868B.0@", "88&8@.@.8H6J", "@@>@J686@B.0", "J88&B@.@J8H6", "T@@>JJ68T@B.", "&88L@.BB", ">@@BJ68J", "8&88.@.B", "@>@@6868", "88&8@.@.", "@@>@J686", "J88&B@.B", "T@@>JJ68", "&88L", ">@@B", "8&88", "@>@@", "88&8", "@@>@", "J88&", "T@@>", }; static const char * dfs9[81] = { "&88LJH8JL6J8LJ88JL88JLJJJLLJJLL^LLL^LLL^Y", ">@@BR@.BB.0@BR@@BB@@BBTBBBTBBBTTTTTVTTTVP", "8&88H868JH6J8J888J888JJJJJLJJJLLLLLLLLLLY", "@>@@@.@.BB.0@@@@@B@@@BBBBBBBBBBTTTTTTTTTP", "88&8868688H6J88888J888JJJJJJJJJLLLLLLLLLG", "@@>@B@.@.@B.0B@@@@B@@@BBBBBTBBBBTTTTTTTTP", "J88&8J686J8H6JJ888JJ88:JJJJLJJJLLLLL^LLLG", "T@@>BB@.@T@B.0B@@@TB@@BTBBBTTBBDTTTTVTTTP", "LJ88(JJ6JLJ8H:JJ88LJJ8:LJJJ^LJJL^LLL^^LLG", "&88LJ68JL6J8LJ88JL88JLJJJLLJJLL^LLL^", ">@@BR@.BB.0@BR@@BB@@BBTBBBTBBBTTTTTV", "8&88H868JH6J8J888J888JJJJJLJJJLLLLLL", "@>@@@.@.BB.0@@@@@B@@@BBBBBBBBBBTTTTT", "88&8868688H6J88888J888JJJJJJJJJLLLLL", "@@>@B@.@.@B.0B@@@@B@@@BBBBBTBBBBTTTT", "J88&8J686J8H6JJ888JJ88:JJJJLJJJLLLLL", "T@@>BB@.@T@B.0B@@@TB@@BTBBBTTBBDTTTT", "LJ88(JJ68LJ8H:JJ88LJJ8:LJJJ^LJJL^LLL", "&88LJ68JL6J8LJ88JL88JLJJJLLJJLLY", ">@@BR@.BB.0@BR@@BB@@BBTBBBTBBBTP", "8&88H868JH6J8J888J888JJJJJLJJJLG", "@>@@@.@.BB.0@@@@@B@@@BBBBBBBBBBP", "88&8868688H6J88888J888JJJJJJJJJG", "@@>@B@.@.@B.0B@@@@B@@@BBBBBTBBB>", "J88&8J686J8H6JJ888JJ88:JJJJLJJJG", "T@@>BB@.@T@B.0B@@@TB@@BTBBBTTBB>", "LJ88(JJ68LJ8H:JJ88LJJ8:LJJJ^LJJG", "&88LJ68JL6J8LJ88JL88JLJJJLL", ">@@BR@.BB.0@BR@@BB@@BBTBBBT", "8&88H868JH6J8J888J888JJJJJL", "@>@@@.@.BB.0@@@@@B@@@BBBBBB", "88&8868688H6J88888J888JJJJJ", "@@>@B@.@.@B.0B@@@@B@@@BBBBB", "J88&8J686J8H6JJ888JJ88:JJJJ", "T@@>BB@.@T@B.0B@@@TB@@BTBBB", "LJ88(JJ68LJ8H:JJ88LJJ8:LJJJ", "&88LJ68JL6J8LJ88JL88JLG", ">@@BR@.BB.0@BR@@BB@@BBP", "8&88H868JH6J8J888J888JG", "@>@@@.@.BB.0@@@@@B@@@B>", "88&8868688H6J88888J888G", "@@>@B@.@.@B.0B@@@@B@@@>", "J88&8J686J8H6JJ888JJ885", "T@@>BB@.@T@B.0B@@@TB@@>", "LJ88(JJ68LJ8H:JJ88LJJ85", "&88LJ68JL6J8LJ88JL", ">@@BR@.BB.0@BR@@BB", "8&88H868JH6J8J888J", "@>@@@.@.BB.0@@@@@B", "88&8868688H6J88888", "@@>@B@.@.@B.0B@@@@", "J88&8J686J8H6JJ888", "T@@>BB@.@T@B.0B@@@", "LJ88(JJ68LJ8H:JJ88", "&88LJ68JL6J8LG", ">@@BR@.BB.0@BP", "8&88H868JH6J8G", "@>@@@.@.BB.0@>", "88&8868688H6J5", "@@>@B@.@.@B.0>", "J88&8J686J8H6G", "T@@>BB@.@T@B.,", "LJ88(JJ68LJ8H5", "&88LJ68JL", ">@@BT@.BB", "8&88H868J", "@>@@@.@.B", "88&886868", "@@>@B@.@.", "J88&8J686", "T@@>BB@.B", "LJ88(JJ68", "&88LG", ">@@BP", "8&88G", "@>@@>", "88&85", "@@>@>", "J88&5", "T@@>>", "LJ88#", }; static const char * dfs10[100] = { "&88LLB.BBV6J8LL@@BBV88JLLBBBTVJJLL^TTTVVLLL^`VVVVh", ">@@BT868JL.0@BT888JL@@BBTJJJLLBBBTVLLLL^TTTVV^^^^`", "8&88L.@.BBH6J8L@@@BB888JLBBBBTJJJLLTTTTVLLLL^VVVVV", "@>@@B6868JB.0@B8888J@@@BBJJJJLBBBBTLLLLLTTTTV^^^^^", "88&88@.@.B8H6J8@@@@BJ888JBBBBBJJJJLTTTTTLLLLLVVVVV", "@@>@@J6868@B.0@J8888B@@@BJJJJJTBBBBLLLLLTTTTT^^^^^", "J88&8B@.@.J8H6JB@@@@JJ888TBBBBLJJJJTTTTT^LL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@BBV88JLLBBBTVJJLL^", ">@@BT868JL.0@BT888JL@@BBTJJJLLBBBTV", "8&88L.@.BBH6J8L@@@BB888JLBBBBTJJJLL", "@>@@B6868JB.0@B8888J@@@BBJJJJLBBBBT", "88&88@.@.B8H6J8@@@@BJ888JBBBBBJJJJL", "@@>@@J6868@B.0@J8888B@@@BJJJJJTBBBB", "J88&8B@.@.J8H6JB@@@@JJ888TBBBBLJJJJ", "T@@>@JJ686T@B.0JJ888TB@@@LJJJJTTBBB", "LJ88&TB@.@LJ8H6TB@@@LJJ88TTBBB^LJJJ", "TT@@>^JJ68TT@B.^JJ88TTB@@^LJJJVTTBB", "&88LL@.BBV6J8LL@@BBV88JLLBBBTV", ">@@BT868JL.0@BT888JL@@BBTJJJLL", "8&88L.@.BBH6J8L@@@BB888JLBBBBT", "@>@@B6868JB.0@B8888J@@@BBJJJJL", "88&88@.@.B8H6J8@@@@BJ888JBBBBB", "@@>@@J6868@B.0@J8888B@@@BJJJJJ", "J88&8B@.@.J8H6JB@@@@JJ888TBBBB", "T@@>@JJ686T@B.0JJ888TB@@@LJJJJ", "LJ88&TB@.@LJ8H6TB@@@LJJ88TTBBB", "TT@@>^JJ68TT@B.^JJ88TTB@@^LJJJ", "&88LL@.BBV6J8LL@@BBV88JLL", ">@@BT868JL.0@BT888JL@@BBT", "8&88L.@.BBH6J8L@@@BB888JL", "@>@@B6868JB.0@B8888J@@@BB", "88&88@.@.B8H6J8@@@@BJ888J", "@@>@@J6868@B.0@J8888B@@@B", "J88&8B@.@.J8H6JB@@@@JJ888", "T@@>@JJ686T@B.0JJ888TB@@@", "LJ88&TB@.@LJ8H6TB@@@LJJ88", "TT@@>^JJ68TT@B.^JJ88TTB@@", "&88LL@.BBV6J8LL@@BBV", ">@@BT868JL.0@BT888JL", "8&88L.@.BBH6J8L@@@BB", "@>@@B6868JB.0@B8888J", "88&88@.@.B8H6J8@@@@B", "@@>@@J6868@B.0@J8888", "J88&8B@.@.J8H6JB@@@@", "T@@>@JJ686T@B.0JJ888", "LJ88&TB@.@LJ8H6TB@@@", "TT@@>^JJ68TT@B.^JJ88", "&88LL@.BBV6J8LL", ">@@BT868JL.0@BT", "8&88L.@.BBH6J8L", "@>@@B6868JB.0@B", "88&88@.@.B8H6J8", "@@>@@J6868@B.0@", "J88&8B@.@.J8H6J", "T@@>@JJ686T@B.0", "LJ88&TB@.@LJ8H6", "TT@@>^JJ68TT@B.", "&88LL@.BBV", ">@@BTJ68JL", "8&88L.@.BB", "@>@@B6868J", "88&88@.@.B", "@@>@@J6868", "J88&8B@.@.", "T@@>@JJ686", "LJ88&TB@.B", "TT@@>^JJ68", "&88LL", ">@@BT", "8&88L", "@>@@B", "88&88", "@@>@@", "J88&8", "T@@>@", "LJ88&", "TT@@>", }; static const char * dfs11[121] = { "&88LL\\H8JL^6J8LL\\88JL^88JLL\\JJLL^JJLL^^LLL^`LLL^`^^^^``^^^``k", ">@@BTR@.BBV.0@BTR@@BBV@@BBTTBBBTVBBBTVTTTTVVTTTVVhVVVVhVVVVhb", "8&88LH868JLH6J8LJ888JL888JLJJJJLLJJJLL^LLLL^LLLL^^^^^^`^^^^`Y", "@>@@BR.@.BBB.0@BR@@@BB@@@BBTBBBBTBBBBTTTTTTVTTTTVVVVVVVVVVVVb", "88&88J6868J8H6J8J8888JJ888JJJJJJLJJJJLLLLLLLLLLLL^^^^^^^^^^^Y", "@@>@@B@.@.B@B.0@B@@@@BB@@@BBBBBBBTBBBBTTTTTTTTTTTVVVVVVVVVVVP", "J88&88J6868J8H6J8J8888JJ888LJJJJJLJJJJLLLLLL^LLLLL^^^^^^^^^^Y", "T@@>@BB@.@.T@B.0BB@@@@TB@@@BTBBBBTTBBBDTTTTTVTTTTVVVVVVhVVVVP", "LJ88&:JJ686LJ8H6LJJ888LJJ88:LJJJJ^LJJJL^LLLL^^LLLN^^^^^`^^^^Y", "TT@@>DTB@.@TT@B.2TB@@@TTB@@DTTBBBVTTBBDVTTTThVTTTVhVVVVhhVVVP", "^LJ88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LJJJJ^LJJJG", "TT@@>DTB@.@TT@B.2TB@@@TTB@@DTTBBBVTTBB>", "^LJ88(^JJ68^LJ8H:^JJ88^LJJ8:^LJJJ^^LJJG", "&88LL\\68JL^6J8LL\\88JL^88JLL\\JJLL^", ">@@BTR@.BBV.0@BTR@@BBV@@BBTTBBBTV", "8&88LH868JLH6J8LJ888JL888JLJJJJLL", "@>@@BR.@.BBB.0@BR@@@BB@@@BBTBBBBT", "88&88J6868J8H6J8J8888JJ888JJJJJJL", "@@>@@B@.@.B@B.0@B@@@@BB@@@BBBBBBB", "J88&88J6868J8H6J8J8888JJ888LJJJJJ", "T@@>@BB@.@.T@B.0BB@@@@TB@@@BTBBBB", "LJ88&:JJ686LJ8H6LJJ888LJJ88:LJJJJ", "TT@@>DTB@.@TT@B.2TB@@@TTB@@DTTBBB", "^LJ88(^JJ68^LJ8H:^JJ88^LJJ8:^LJJJ", "&88LL\\68JL^6J8LL\\88JL^88JLLY", ">@@BTR@.BBV.0@BTR@@BBV@@BBTP", "8&88LH868JLH6J8LJ888JL888JLG", "@>@@BR.@.BBB.0@BR@@@BB@@@BBP", "88&88J6868J8H6J8J8888JJ888JG", "@@>@@B@.@.B@B.0@B@@@@BB@@@B>", "J88&88J6868J8H6J8J8888JJ888G", "T@@>@BB@.@.T@B.0BB@@@@TB@@@>", "LJ88&:JJ686LJ8H6LJJ888LJJ885", "TT@@>DTB@.@TT@B.2TB@@@TTB@@>", "^LJ88(^JJ68^LJ8H:^JJ88^LJJ85", "&88LL\\68JL^6J8LL\\88JL^", ">@@BTR@.BBV.0@BTR@@BBV", "8&88LH868JLH6J8LJ888JL", "@>@@BR.@.BBB.0@BR@@@BB", "88&88J6868J8H6J8J8888J", "@@>@@B@.@.B@B.0@B@@@@B", "J88&88J6868J8H6J8J8888", "T@@>@BB@.@.T@B.0BB@@@@", "LJ88&:JJ686LJ8H6LJJ888", "TT@@>DTB@.@TT@B.2TB@@@", "^LJ88(^JJ68^LJ8H:^JJ88", "&88LL\\68JL^6J8LLY", ">@@BTR@.BBV.0@BTP", "8&88LH868JLH6J8LG", "@>@@BR.@.BBB.0@BP", "88&88J6868J8H6J8G", "@@>@@B@.@.B@B.0@>", "J88&88J6868J8H6J5", "T@@>@BB@.@.T@B.0>", "LJ88&:JJ686LJ8H6G", "TT@@>DTB@.@TT@B.,", "^LJ88(^JJ68^LJ8H5", "&88LL\\68JL^", ">@@BTT@.BBV", "8&88LH868JL", "@>@@BR.@.BB", "88&88J6868J", "@@>@@B@.@.B", "J88&88J6868", "T@@>@BB@.@.", "LJ88&:JJ686", "TT@@>DTB@.B", "^LJ88(^JJ68", "&88LLY", ">@@BTP", "8&88LG", "@>@@BP", "88&88G", "@@>@@>", "J88&85", "T@@>@>", "LJ88&5", "TT@@>>", "^LJ88#", }; static const char * dfs12[144] = { "&88LL`B.BBVV6J8LL`@@BBVV88JLL`BBBTVVJJLL^`TTTVVhLLL^``VVVVhj^^^``rhhhhjj", ">@@BTV868JL^.0@BTV888JL^@@BBTVJJJLL^BBBTVVLLLL^`TTTVVh^^^^``VVVVhj`````r", "8&88LL.@.BBVH6J8LL@@@BBV888JLLBBBBTVJJJLL^TTTTVVLLLL^`VVVVVh^^^^``hhhhhj", "@>@@BT6868JLB.0@BT8888JL@@@BBTJJJJLLBBBBTVLLLLL^TTTTVV^^^^^`VVVVVh``````", "88&88L@.@.BB8H6J8L@@@@BBJ888JLBBBBBTJJJJLLTTTTTVLLLLL^VVVVVV^^^^^`hhhhhh", "@@>@@BJ6868J@B.0@BJ8888JB@@@BBJJJJJLTBBBBTLLLLLLTTTTTV^^^^^^VVVVVV``````", "J88&88B@.@.BJ8H6J8B@@@@BJJ888JTBBBBBLJJJJLTTTTTT^LLLLLVVVVVV^^^^^^hhhhhh", "T@@>@@JJ6868T@B.0@JJ8888TB@@@BLJJJJJTTBBBB^LLLLLVTTTTT^^^^^^hVVVVV``````", "LJ88&8TB@.@.LJ8H6JTB@@@@LJJ888TTBBBB^LJJJJVTTTTT^^L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@@BBV888JLLBBBBTVJJJLL^", "@>@@BT6868JLB.0@BT8888JL@@@BBTJJJJLLBBBBTV", "88&88L@.@.BB8H6J8L@@@@BBJ888JLBBBBBTJJJJLL", "@@>@@BJ6868J@B.0@BJ8888JB@@@BBJJJJJLTBBBBT", "J88&88B@.@.BJ8H6J8B@@@@BJJ888JTBBBBBLJJJJL", "T@@>@@JJ6868T@B.0@JJ8888TB@@@BLJJJJJTTBBBB", "LJ88&8TB@.@.LJ8H6JTB@@@@LJJ888TTBBBB^LJJJJ", "TT@@>@^JJ686TT@B.0^JJ888TTB@@@^LJJJJVTTBBB", "^LJ88&VTB@.@^LJ8H6VTB@@@^LJJ88VTTBBB^^LJJJ", "hTT@@>^^JJ68hTT@B.^^JJ88hTTB@@^^LJJJhVTTBB", "&88LL`@.BBVV6J8LL`@@BBVV88JLL`BBBTVV", ">@@BTV868JL^.0@BTV888JL^@@BBTVJJJLL^", "8&88LL.@.BBVH6J8LL@@@BBV888JLLBBBBTV", "@>@@BT6868JLB.0@BT8888JL@@@BBTJJJJLL", "88&88L@.@.BB8H6J8L@@@@BBJ888JLBBBBBT", "@@>@@BJ6868J@B.0@BJ8888JB@@@BBJJJJJL", "J88&88B@.@.BJ8H6J8B@@@@BJJ888JTBBBBB", "T@@>@@JJ6868T@B.0@JJ8888TB@@@BLJJJJJ", "LJ88&8TB@.@.LJ8H6JTB@@@@LJJ888TTBBBB", "TT@@>@^JJ686TT@B.0^JJ888TTB@@@^LJJJJ", "^LJ88&VTB@.@^LJ8H6VTB@@@^LJJ88VTTBBB", "hTT@@>^^JJ68hTT@B.^^JJ88hTTB@@^^LJJJ", "&88LL`@.BBVV6J8LL`@@BBVV88JLL`", ">@@BTV868JL^.0@BTV888JL^@@BBTV", "8&88LL.@.BBVH6J8LL@@@BBV888JLL", "@>@@BT6868JLB.0@BT8888JL@@@BBT", "88&88L@.@.BB8H6J8L@@@@BBJ888JL", "@@>@@BJ6868J@B.0@BJ8888JB@@@BB", "J88&88B@.@.BJ8H6J8B@@@@BJJ888J", "T@@>@@JJ6868T@B.0@JJ8888TB@@@B", "LJ88&8TB@.@.LJ8H6JTB@@@@LJJ888", "TT@@>@^JJ686TT@B.0^JJ888TTB@@@", "^LJ88&VTB@.@^LJ8H6VTB@@@^LJJ88", "hTT@@>^^JJ68hTT@B.^^JJ88hTTB@@", "&88LL`@.BBVV6J8LL`@@BBVV", ">@@BTV868JL^.0@BTV888JL^", "8&88LL.@.BBVH6J8LL@@@BBV", "@>@@BT6868JLB.0@BT8888JL", "88&88L@.@.BB8H6J8L@@@@BB", "@@>@@BJ6868J@B.0@BJ8888J", "J88&88B@.@.BJ8H6J8B@@@@B", "T@@>@@JJ6868T@B.0@JJ8888", "LJ88&8TB@.@.LJ8H6JTB@@@@", "TT@@>@^JJ686TT@B.0^JJ888", "^LJ88&VTB@.@^LJ8H6VTB@@@", "hTT@@>^^JJ68hTT@B.^^JJ88", "&88LL`@.BBVV6J8LL`", ">@@BTV868JL^.0@BTV", "8&88LL.@.BBVH6J8LL", "@>@@BT6868JLB.0@BT", "88&88L@.@.BB8H6J8L", "@@>@@BJ6868J@B.0@B", "J88&88B@.@.BJ8H6J8", "T@@>@@JJ6868T@B.0@", "LJ88&8TB@.@.LJ8H6J", "TT@@>@^JJ686TT@B.0", "^LJ88&VTB@.@^LJ8H6", "hTT@@>^^JJ68hTT@B.", "&88LL`@.BBVV", ">@@BTVJ68JL^", "8&88LL.@.BBV", "@>@@BT6868JL", "88&88L@.@.BB", "@@>@@BJ6868J", "J88&88B@.@.B", "T@@>@@JJ6868", "LJ88&8TB@.@.", "TT@@>@^JJ686", "^LJ88&VTB@.B", "hTT@@>^^JJ68", "&88LL`", ">@@BTV", "8&88LL", "@>@@BT", "88&88L", "@@>@@B", "J88&88", "T@@>@@", "LJ88&8", "TT@@>@", "^LJ88&", "hTT@@>", }; static const char ** dfss[12] = { (const char **) dfs1, (const char **) dfs2, (const char **) dfs3, (const char **) dfs4, (const char **) dfs5, (const char **) dfs6, (const char **) dfs7, (const char **) dfs8, (const char **) dfs9, (const char **) dfs10, (const char **) dfs11, (const char **) dfs12, }; static char get_my_dfs(int ll, int i, int j, int ii, int jj) { int yy; char dfs; if (i>ii) { int t; t=i; i=ii; ii=t; t=j; j=jj; jj=t; } yy=(ii-i)*ll + jj; dfs = dfss[ll-1][i*ll+j][yy>>1] - 35; if (yy&1) return dfs%9; else return dfs/9; } int my_abs(int a) { if (a>=0) return a; return -a; } int my_min(int a, int b) { if (a<b) return a; return b; } int my_max(int a, int b) { if (a>b) return a; return b; } int start_x,start_y; int end_x,end_y; int l; int reduce_range() { int min_x, min_y, max_x, max_y; int range_x0, range_y0, range_x1, range_y1; int width, height; min_x = my_min(start_x, end_x); range_x0 = my_max(0, min_x-3); min_y = my_min(start_y, end_y); range_y0 = my_max(0, min_y-3); max_x = my_max(start_x, end_x); range_x1 = my_min(l, max_x+4); max_y = my_max(start_y, end_y); range_y1 = my_min(l, max_y+4); width = range_x1-range_x0; height = range_y1-range_y0; l = my_max(width, height); start_x -= range_x0; end_x -= range_x0; start_y -= range_y0; end_y -= range_y0; return l<=maxn; } static int step_other_diff[7]; static unsigned int step_other_diff_count; int get_step_other_diff(unsigned int step, int other_end) { int i; step_other_diff_count = 0; i = (step&1); for (; i<=step && step_other_diff_count<4; i+=2) { if (other_end+i<l) step_other_diff[step_other_diff_count++] = i; else break; } i = (step&1); if (i == 0) i = 2; for (; i<=step && step_other_diff_count<7; i+=2) { if (other_end>=i) step_other_diff[step_other_diff_count++] = -i; else break; } return 0; } int reduce() { int start_step = 0; int diff_x, diff_y, min_diff_xy; int diff_xy; // 缩短x,y坐标差 diff_x = my_abs(start_x-end_x); diff_y = my_abs(start_y-end_y); min_diff_xy = my_min(diff_x, diff_y); diff_xy = my_abs(diff_x-diff_y); if (min_diff_xy >= max_distance+3 && diff_xy > 0) { int sss, sss_x, sss_y; if (diff_x > diff_y) { sss = my_min((diff_x-max_distance)>>1, diff_y-max_distance); sss = my_min(sss, diff_xy); sss_x = sss<<1; sss_y = sss; } else { sss = my_min((diff_y-max_distance)>>1, diff_x-max_distance); sss = my_min(sss, diff_xy); sss_x = sss; sss_y = sss<<1; } start_step += sss; if (end_x > start_x) end_x -= sss_x; else end_x += sss_x; if (end_y > start_y) end_y -= sss_y; else end_y += sss_y; diff_x = my_abs(start_x-end_x); diff_y = my_abs(start_y-end_y); min_diff_xy = my_min(diff_x, diff_y); } // 使x,y坐标差较小的减小到max_distance以内 if (min_diff_xy >= max_distance+3) { int inter_two = (int)((min_diff_xy-max_distance)/3); int inter_xy = inter_two * 3; start_step += (inter_two << 1); if (end_x > start_x) end_x -= inter_xy; else end_x += inter_xy; if (end_y > start_y) end_y -= inter_xy; else end_y += inter_xy; diff_x = my_abs(start_x-end_x); diff_y = my_abs(start_y-end_y); } // 减小大的坐标差 if (diff_x > diff_y && diff_x >= max_distance+3) { unsigned int diff_step = (diff_x-max_distance)>>1; unsigned int min_next_step = 0xffffff, next_step; int i; start_step += diff_step; get_step_other_diff(diff_step, end_y); if (end_x > start_x) end_x -= (diff_step<<1); else end_x += (diff_step<<1); for (i=0; i<step_other_diff_count; ++i) { int s_start_x = start_x; int s_start_y = start_y; int s_end_x = end_x; int s_end_y = end_y; int s_l = l; end_y += step_other_diff[i]; diff_y = my_abs(start_y-end_y); if (diff_y < maxn && reduce_range()) { next_step = get_my_dfs(l, start_x, start_y, end_x, end_y); if (min_next_step > next_step) min_next_step = next_step; } start_x = s_start_x; start_y = s_start_y; end_x = s_end_x; end_y = s_end_y; l = s_l; } start_step += min_next_step; return start_step; } else if (diff_x < diff_y && diff_y >= max_distance+3) { unsigned int diff_step = (diff_y-max_distance)>>1; unsigned int min_next_step = 0xffffff, next_step; int i; start_step += diff_step; get_step_other_diff(diff_step, end_x); if (end_y > start_y) end_y -= (diff_step<<1); else end_y += (diff_step<<1); for (i=0; i<step_other_diff_count; ++i) { int s_start_x = start_x; int s_start_y = start_y; int s_end_x = end_x; int s_end_y = end_y; int s_l = l; end_x += step_other_diff[i]; diff_x = my_abs(start_x-end_x); if (diff_x < maxn && reduce_range()) { next_step = get_my_dfs(l, start_x, start_y, end_x, end_y); if (min_next_step > next_step) min_next_step = next_step; } start_x = s_start_x; start_y = s_start_y; end_x = s_end_x; end_y = s_end_y; l = s_l; } start_step += min_next_step; return start_step; } reduce_range(); start_step += get_my_dfs(l, start_x, start_y, end_x, end_y); return start_step; } int main() { char line[128]; int n, i; int step; gets(line); n = atoi(line); for(i = 0; i < n; i++) { gets(line); l = atoi(line); gets(line); start_x = atoi(line); start_y = atoi(strchr(line, ' ')+1); gets(line); end_x = atoi(line); end_y = atoi(strchr(line, ' ')+1); step = reduce(); printf("%d\n", step); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator