1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
#include <bits/stdc++.h> using namespace std;
unsigned cnt = 256;
struct Link{ char ch; map<unsigned, Link*> m; Link *father; Link(): father(nullptr) {} };
Link link[100000];
unsigned content[] = {48, 49, 50, 51, 52, 95, 53, 95, 54, 43, 95, 55, 56, 57, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 64, 91, 92, 93, 94, 95, 96, 123, 124, 125, 126, 102, 108, 97, 103, 123, 125, 10, 84, 111, 32, 98, 101, 44, 32, 111, 114, 32, 283, 116, 32, 116, 362, 364, 366, 116, 104, 97, 372, 105, 115, 373, 104, 101, 32, 113, 117, 101, 288, 105, 111, 110, 58, 10, 87, 385, 378, 101, 369, 39, 116, 382, 370, 111, 98, 108, 400, 32, 105, 110, 384, 386, 109, 411, 100, 373, 362, 115, 117, 102, 102, 400, 360, 385, 32, 115, 108, 411, 103, 383, 97, 110, 417, 97, 114, 114, 111, 119, 383, 111, 102, 367, 117, 116, 114, 356, 101, 111, 117, 383, 102, 368, 289, 110, 365, 10, 79, 369, 374, 373, 97, 107, 386, 436, 109, 432, 103, 97, 411, 288, 32, 97, 427, 101, 474, 442, 373, 438, 117, 407, 390, 10, 65, 434, 363, 121, 367, 112, 112, 111, 115, 430, 32, 101, 486, 399, 109, 46, 32, 361, 32, 100, 105, 101, 226, 128, 148, 461, 428, 101, 101, 112, 44, 10, 78, 362, 109, 368, 101, 59, 473, 486, 98, 488, 474, 511, 513, 418, 427, 97, 488, 119, 386, 496, 100, 425, 386, 385, 436, 116, 45, 97, 99, 426, 433, 417, 399, 384, 450, 115, 547, 370, 380, 117, 447, 108, 427, 104, 111, 99, 107, 115, 425, 380, 32, 354, 390, 104, 410, 383, 385, 105, 460, 111, 58, 32, 402, 404, 474, 99, 393, 420, 109, 109, 380, 392, 110, 10, 68, 101, 118, 450, 116, 108, 488, 461, 364, 32, 119, 382, 104, 39, 100, 500, 502, 504, 365, 530, 528, 112, 59, 360, 419, 408, 513, 366, 112, 400, 545, 433, 99, 386, 461, 100, 114, 476, 109, 507, 148, 532, 377, 385, 627, 39, 383, 549, 114, 481, 395, 70, 368, 410, 412, 378, 566, 611, 367, 443, 273, 380, 570, 119, 379, 372, 626, 628, 383, 586, 488, 582, 109, 457, 397, 496, 600, 539, 97, 118, 386, 115, 104, 421, 568, 417, 442, 443, 378, 404, 519, 114, 116, 97, 558, 582, 105, 108, 515, 77, 451, 372, 103, 105, 670, 32, 451, 32, 112, 97, 451, 506, 508, 399, 635, 637, 426, 627, 115, 619, 99, 116, 565, 372, 586, 464, 383, 99, 684, 97, 415, 116, 488, 478, 115, 362, 108, 393, 103, 32, 429, 423, 46, 10, 642, 369, 654, 362, 119, 450, 108, 417, 364, 436, 413, 600, 277, 112, 432, 486, 115, 582, 114, 110, 441, 678, 105, 663, 515, 84, 603, 284, 112, 708, 725, 114, 636, 600, 438, 110, 103, 633, 386, 763, 450, 417, 586, 110, 767, 582, 110, 289, 663, 596, 759, 426, 699, 770, 755, 503, 382, 763, 105, 122, 604, 730, 111, 670, 772, 730, 97, 119, 767, 273, 355, 121, 515, 354, 356, 123, 374, 95, 364, 95, 368, 95, 371, 95, 811, 364, 359, 760, 386, 471, 111, 408, 110, 623, 649, 649, 102, 105, 623, 366, 553, 549, 709, 556, 754, 713, 698, 587, 496, 714, 400, 105, 372, 478, 378, 39, 117, 110, 739, 682, 104, 597, 463, 390, 515, 665, 412, 426, 277, 467, 101, 108, 443, 415, 276, 372, 277, 383, 388, 505, 289, 659, 857, 396, 846, 570, 474, 98, 436, 386, 98, 111, 100, 107, 411, 63, 32, 397, 738, 740, 417, 102, 436, 804, 383, 743, 114, 759, 362, 103, 639, 781, 523, 417, 115, 534, 566, 851, 273, 369, 474, 910, 114, 488, 731, 457, 66, 445, 384, 566, 549, 657, 97, 676, 443, 725, 663, 679, 770, 473, 102, 116, 409, 651, 378, 785, 386, 912, 382, 582, 670, 635, 417, 582, 851, 446, 806, 567, 438, 109, 746, 492, 884, 450, 753, 516, 362, 446, 669, 865, 408, 369, 627, 289, 753, 115, 618, 117, 122, 122, 408, 706, 386, 601, 108, 688, 484, 486, 715, 390, 696, 383, 447, 704, 363, 476, 460, 560, 115, 823, 979, 383, 534, 32, 379, 670, 565, 412, 354, 597, 362, 111, 704, 706, 566, 997, 107, 283, 119, 405, 847, 102, 63, 425, 697, 780, 751, 505, 827, 386, 100, 111, 984, 983, 32, 582, 119, 897, 789, 697, 684, 980, 485, 548, 673, 976, 554, 403, 695, 673, 386, 478, 708, 825, 445, 588, 10, 73, 383, 493, 562, 429, 101, 676, 39, 409, 601, 378, 745, 699, 408, 1029, 97, 472, 848, 560, 117, 869, 515, 1037, 495, 781, 400, 792, 993, 789, 904, 476, 372, 112, 846, 545, 907, 32, 519, 663, 781, 878, 1062, 679, 986, 101, 469, 114, 1038, 101, 574, 1029, 556, 627, 781, 637, 838, 473, 119, 917, 981, 417, 727, 993, 745, 110, 720, 1045, 443, 544, 403, 393, 733};
int main(){ memset(link, 0, sizeof(link)); for(int i = 0; i != 100000; ++i) link[i].m = map<unsigned, Link*>(); string ans; Link fakehead; for(int i = 0; i != 256; ++i){ link[i].ch = i; link[i].father = &fakehead; fakehead.m[i] = &link[i]; }
ans += content[0]; for(int i = 0; i != 868-1; ++i){ unsigned cur = content[i]; Link *now = &link[cur];
if(now->father != &fakehead){ string tmp; Link *nownow = now; while(nownow->father != &fakehead){ tmp = nownow->ch + tmp; nownow = nownow->father; } ans += tmp; }
Link *fath = &link[content[i+1]]; while(fath->father != &fakehead) { fath = fath->father; } ans.push_back(fath->ch);
link[cnt].ch = fath->ch; link[cnt].father = now; now->m[fath->ch] = &link[cnt++]; } cout << ans << endl; return 0; }
|