Blue Bridge Cup 2018 java group C real question 100100 matrix to find LANQIAO

Hits: 0

Code:

package sample_test.twoTree;

public  class  Demo02 { 
    public  static  void  main (String[] args)  {
         int count = 0 ;
        String str = "FOAIQNALWIKEGNICJWAOSXDHTHZPOLGYELORAUHOHCZIERPTOOJUITQJCFNIYYQHSBEABBQZPNGYQTCLSKZFCYWDGOAIADKLSNGJ\n" +
                 "\n" +
                 "GSOZTQKCCSDWGUWAUOZKNILGVNLMCLXQVBJENIHIVLRPVVXXFTHQUXUAVZZOFFJHYLMGTLANQIAOQQILCDCJERJASNCTLYGRMHGF\n" +
                 "\n" +
                 "TSDFYTLVIBHKLJVVJUDMKGJZGNNSTPVLCKTOFMUEUFSVQIAUVHNVFTGBDDARPKYNNCUOYUAZXQJNOEEYKLFRMOEMHUKJTPETHLES\n" +
                "\n" +
                "FKVINSLWEVGAGMKVFVIUBMYOIAFHLVNKNTYKTZWVXQWRWIGPENFXYDTKRVPKRTHMGHVYOCLDCKMEKRLGEKBYUCLOLYPAKPFSOREH\n" +
                "\n" +
                "KWPUOLOVMOFBIXYACWRDYBINTMPASPCEOKHXQIGBQQMCEOIVULIEOPFSCSIHENAJCVDPJDOIWIIULFDNOZOFVAMCABVGKAKCOZMG\n" +
                "\n" +
                "XWMYRTAFGFOCNHLBGNGOXPJSTWLZUNNAGIRETGXFWAQSSJPFTQAXMTQWMZWYVEPQERKSWTSCHSQOOBGXAQTBCHOEGBDVKGWJIFTG\n" +
                "\n" +
                "ZWWJEIISPLMXIMGHOOGDRZFTGNDDWDWMNUFWJYJGULPHNUFSAQNNIUVAAFZIAZKFXXNWCEABGJAUMGYEIEFVQXVHHHEDYUITRCQB\n" +
                "\n" +
                "XZHDPZQTOBECJVBZLACVXACZEDYOGVAVQRNWEOWGRAQYUEUESTEDQTYJUTEFOOITSHDDZHONJGBRCWNEQLZUTBNQIADKNFIOMWZR\n" +
                "\n" +
                "EBFKCVNLURZSNPOLTISRPDTNUMCDGKTYRGIOVEPTUTSBAWQKWWEUWIWHAANUZUADGZEATZOQICWFUJTWNZDBKLQNELWVTBNDLNFH\n" +
                "\n" +
                "PESISEATZNCDFRMXBQUKBFTIGYSFCWVHPMSUSDKPSCOMVLDOHYQVFHAJKRDTAVLIMNZBZSMLMRTLRPSLAHXDBASDMWAAYBPYVJZF\n" +
                "\n" +
                "SCCWYHLQOUKBMCEYENQNJXFOMOOJMTKDSHJJOHDKEGATFZHGWJJAZJROWHAZUFGEQKPYXLCAAXHHQBDALPYUDWZQHBASBBCFGQCQ\n" +
                "\n" +
                "ZKNXUBRYZVSPQHOVLAEUAUITMPWXNXJQVIBJVBCSVXKWFAFRPRWOLYVSDVTGGOFFMNQJZOBUDJLFHJTCYMPNOBHQJHGKLIKLZMLA\n" +
                "\n" +
                "POCKVEQXUAVHERIAQLGJHYOOVOMTXQFRTBFSETOZICPCHZHFBWNESVJJLSVSVOOGYYABFESWNWDNYBGBNAKRCFQMTCUMIFTESVIN\n" +
                "\n" +
                "JCAULIQRYUMAMAOVVWSEUTMECXSDTONRMMROQUISYEURSAYNZUVOPXLIFBDOHPXMABBLEQZGLJXQJOEYYRRRCFTEZQAOIWKRJQDL\n" +
                "\n" +
                "ZNUUDWZXZZURPMHGXQGNQBIQWWNERZWULSAPIBODBFFQQIHEQKCKLJYQNXQUTAAYGRBXSLLQNOQPZJEWHETQHPXJANMJFOHINWOW\n" +
                "\n" +
                "KJGAWWFSVIZHFNUWBLWYVPIWAEICCAHOEIWRADSLOZGPSVGPUBUUQAVYCHOIGINKYKJABWAQCZCXOBKTNJZQRHLUFKQLACAAOIWJ\n" +
                "\n" +
                "SIKWLXQHKDFJVGBVXWDWJKUSFRQRTDJYQMNFOQQALHRLMHSDMCFLAOVKDMTKMTPVTLAZLYJNJXZCFRHHSDIXYUUSVIMIICLUJHFW\n" +
                "\n" +
                "JHWUSMCFYHPIXHAPBBSHYDQCKVGQFTENLVERFVOVDCLSTQFUSEPUMTFODLZLYQXDOXAEPONIQWTDWSAWBNSZYACGSJQSHAUMIKXT\n" +
                "\n" +
                "MVBNFXMFNPAYSODPXEAYNRKTEZJWMUACSIUYPIORUFPMXAOZZJPJXPFLNSKNIAMETMOVULZPQIJJIRCSYQXOEVRHCNACSBRHKYNW\n" +
                "\n" +
                "KGKBTBHGWKVJYZCOVNSKUREKZEIWVLOHAMUAYKLUGHEUESICBZAHURNTJAECTHRNKSIJQFIPVZANSZYSPJWHPKHCAPEYWNXUYQSD\n" +
                "\n" +
                "RRRFYQFIQSWYRQTSNGNUFOBMSLGAFWPJGYEHGASFKTJCCZPXFIQLSXNKNWCYVTETOAPCOZJNHEWOCCAWVDEZUQCLLAVUQJJTQCKJ\n" +
                "\n" +
                "NMBKMUENVGXXVMQCLXPJDQIQCFWYADIFDSGINGZDJYHPUPXVRMWDIPJRWPNRYOFGYYPEAVKDEMLYRRRMNCRQXPTDSQIVKKGJWDEF\n" +
                "\n" +
                "SBAEKIFZCKDOMIQKBDWVQGBYWPDIBOLQUGAQRXLJDAZMXVZXYSNWEWTNZKYREMBEUHOTFOCKEJSXCMUBCKXNGQXTQJRCRCLWJTOI\n" +
                "\n" +
                "YXBFBIBRAAFNPKBLTSMCFERZURZNWHMOEHIHNQTBWXNPJGIDYDPRGEWACCBULJRACOFLANQIAOIHMYCNQHVKXSIGAMWAHUSNBBTD\n" +
                "\n" +
                "QDGPTRONXHAZWOUPNBFJFEWAMFZUQZFDKAPNJUBQPWBPYGPZHKUDZZDLCCWHGAUKJCSLLFWGPYJKJQBNLCZESOGXXSQCVVKVRVAW\n" +
                "\n" +
                "NXPGQOUEFLUZHHSAODIWEPZLXVQLYGVOOVCCREDJZJOMCSCFFKEIEAVCTPUZOWNOLJHGBJHJFBFFORGXOXXFOCAGBWEFCIDEKDLB\n" +
                "\n" +
                "PTXSUINQAJURNFQPMMSPLZTQAHCIOFJUEFFZGIHTSJNIEXQLLHRQUXXLLORJEHGQJOXSLIAVFPEJNGMMVAXDDMPXLOSTRLLFLYRM\n" +
                "\n" +
                "JQNCLENGTROIKDWBMXRNJYPGZRQOREPJJPTXKVVKPYYZENEOIQKZOPXAYGFXORXRIDGATHMZFDJIOIOKVDJBHSXQMYCBYFGXWHLH\n" +
                "\n" +
                "CITGTILGPGBHZMNWWHXEFPGDPJUVFBJKAQWACZHPRPJYCOLGZTBDCVHNRSUAJUQAWAPMQJDQIFPZQZEONWHIYKMXDZOMVETEFJRB\n" +
                "\n" +
                "RDOTIDCFEESOKYPYCGQQKOGPMGJRITSVTKOKDSXLRLJRRHNFRFXCMDNQMCEGZFJWHZOAFBQXXPXNBSWTSUYPAWQRHAUGLNPBRSJT\n" +
                "\n" +
                "HOWRIUGMOQTUYIHDWJRFBWWKWYKCICSVBVKTBIIWGFSVIFCTUKIHHUUISCOTEOYRWQXTAEBXQQOLLMOALNIYVCCHNSWIKHMYYNZO\n" +
                "\n" +
                "OFRIYYXPPSRTPAYMUJSSDILKIZAYSEIOLANQIAOVKARDPGVFCSYBSNHAPGTIKLAWTTKOEADWRLAACAAFYTBTNSGFTYLYUHJXBMMA\n" +
                "\n" +
                "NJFTMLUIBKDPWBXQOMBVQXCZOIREHRSZCSJOIVBXWQIBUTYBQNTZRVROHGOIZYAJWXLEATLOZJIKJMIHSLGSVTCXJWIOOGWSERRQ\n" +
                "\n" +
                "DBQJNGBLRIYFIKHBEYOZQBOAGGNIZKFDHWXCFNJLBQXVLHIQNIBZSDLTTRERHNWCMLJCVBBGGAQTPUQHIRABXPQSYGSDVMBNNDFG\n" +
                "\n" +
                "KPLFUYXHYGOCZPPXMWCZYNKCYBCRZVKFBHQXPGPBZFTTGEPQTJMOFHAYSQQZDMQECGXOXADYHNNXUKNBXZBYHBOULXNBJZKIZREF\n" +
                "\n" +
                "LVHAMSNXJOCVRPVGJUWXFVOCUCLCZDXRPBBDRLRAVVNLOZWOHWMXYSNMXAKJYWYGILNGUJGIPKAUDVANZLFWKUWWUSQYBRCBVDIJ\n" +
                "\n" +
                "QCXPLOTPPGXCUZOUSSTXHVMLHVMJTUSSOPLRKEBQSGWNGVHKANVZWYQHSHLIPWSYCPKTUKPMWPLVFLLAHXZQANFXHFNYHIQVIOYN\n" +
                "\n" +
                "ZPTJJCBHXPSUPOMNRVCKXSUFCNRCRNCPTPGIDQOEQUDFNUNMJPOEKVIMUJAJZOUKMAFSLDWYMCHTSNJYUDJAHQOIXPYSRHVAFFCR\n" +
                "\n" +
                "DCGMEEWXWMNOSSJNIZCINRHENPPPCYVFWYCONOPKXMFZXXIHNXIGAHAMHSBRESOETGVXWDNQLGCEOUDDJXHQIVCHRNKBFFEWILGY\n" +
                "\n" +
                "SOAIQNALXRBSGAQIDQVMVDKVZCPMJNXKXRXPFZAUVQPBHHQKTPDSQROLQTUGMFQRWGVEWCYPDYDZGNNNUFKJUEHJKPLIQNRQYXHU\n" +
                "\n" +
                "GKGWUCJXUKAEHLRLNDFUQPSJAZTVJRXWXQVBMRJXULEMJJPDCVTOWVFDBVLSBHZRRQUVMUQYKTJCLSGGHGCPHPHMWYAECLJIZUWV\n" +
                "\n" +
                "QQNKPQRJMSOCEAYDNKPHVEGKAGCKAPDXTGVXULHUXHJPDXCSKQTCJENVTZTMRUENCSWHBEORALSREBWAJEMQDXMRKGHJGICDHKHY\n" +
                "\n" +
                "YNSDSWDRLBBFUFVVICMGUCGBSVDLJNXGKXNFGVLKAVBJRRRUHKRXTPBJAKIEBAVMDIOJLIUDABCGNPNJIYBCXMOOWKRPHPYSWRDC\n" +
                "\n" +
                "BORWTNBISSLTVKBRTLWKRNCEDCNEGCIYJIPDICFAVNOISYAHWBLGMNFKXZYTTWJOBEPNMSJEJMHXVPGOJOLQQQVXFGEULANQIAOD\n" +
                "\n" +
                "OQETOJHCZXGTUKIWGMEVVMXCURISUOFQSAWZWDMZWVYHZMPEIMWKJDGERODVVUXYRTYLCRGYQQOIOFZSSZRAIESWBQOAIQNALJNR\n" +
                "\n" +
                "HEYWHPLLPCUEOCBAOWGAYEJZQJHLVNMVQNSQQGGUBOIMDPFLOVSQGBLYAMBRYJDVOXOQINLJAVYALAKHPKOYNKGXIISSJNGKHYMS\n" +
                "\n" +
                "IQVRYKXCUFIRNENEXFJTMOTJWYXSMTDHHPRHWIXETWVVIXZELKLLWRWQYGBCGJNYSUQEFCOUDNIJMLJNLAWSYJGULKBCFPYVSSMW\n" +
                "\n" +
                "WQHGWRQFWFOTGPBBSJBDUKOMBXNRPIMCGPGVZFADWTBVIEMVTBXVAFQDDMJALCOMZTXUFFKBQQZDFAMTFWEXTHBKNWRLUVITQXLN\n" +
                "\n" +
                "OPPJQKNGHWWPENVQIABJCQNKXNPWOWRFEOKQPQLANQIAORGGOLAYCEGZBHZVLPBERWYIJNJUNXKULUQOJLTNRDZDEYWEMYCHJLLB\n" +
                "\n" +
                "LJISOAQLXJEFXVTOZSICOLQIJEXUANJWIFSIMGUQWHBXUDWOEILYFUZTGDZDSPLZPDPXBLFAXLEFQFEPDSJQWEQMXKKHCXHMSATM\n" +
                "\n" +
                "UMUJENPBYKZLWAJAXJKDIYCBREBPOETQHMRHLKSEZUIPRGWIZDDQLSJAPKPBWMJMPZWLNFLFCQOCDBMLIHIYCXUJLFLPZVGWBKMY\n" +
                "\n" +
                "WHZJLKEWUPETVUREKVKCLBNYFLWCERVIPUDINNWGQTUHWXCTDVTMYATYUZLMVLOHKBOGIZCQDOWFBCWJAVUXYUEVRKPOXCKHAWZC\n" +
                "\n" +
                "RPLNLCUHJRADHJNSDPZXIKXGUKEJZCFJQASVUBSNLXCJXVCJZXGMRYRLOBCNGPDUJQVEFKMYHNZGZOAIQNALQDHTBWJXPKJLFXJY\n" +
                "\n" +
                "MKCEZEDAFGSOCORWJGMOKWPVVBVDYZDZHPXFWJBDELHPGOQHMBAHUUUJMGXAEKZCTQTBXNVYUIQUVZGXSKQXJWRUPSFIJDYIAORC\n" +
                "\n" +
                "GKFKQNXPJWOPPBTUKTHUBIROSYOVFEMJBRREWICJPCIOSTWPAUSKTRQULXPWRSXHSRYBCWYCYOTCTPFSQLDIILIGMEVZKYSOYRPH\n" +
                "\n" +
                "SFDSCSMLLNARCCGCBJOGZAEQTGNGSFAQIXLPDBSWZDTYVASYYPVBRFBTIAGGWONGSVKCJDBBLYKAIOXUATGMALZXFOHZFTXALCFU\n" +
                "\n" +
                "CUSSTLCRYPDTFSFJFENKJWTEBOBEPLSNXLALQWCKSLVMZQDJITHZKVCCQXTEXOSVAUFYAZXJUOAPPVEEWOIIMOSZZMCOQBRUXWKG\n" +
                "\n" +
                "PDOFSCKKJJTRYRWGLEZODQTJSIMXIAOLNMLPHBAYLPTTLPYWILSEIIQVSXNHIJEORVCNJHYXRBIZZJTADGMRTSXVRXYGVQQNUEIC\n" +
                "\n" +
                "IHNJOQXUXTXFPALCHOELNVMWDWQTEARUKPIFWXJSMWZLMNLAODUTKNZDYRFRLGBLIBGIBXJBOYMLYLANQIAORORYKSJPOOOAMVRN\n" +
                "\n" +
                "IWIUHLYJKTQGVJBDPROSRGZUFITDIBCDPICNEFIGHWGSROWBYKUCLCQYLJXLHLXSCTJWKDLHHMLDBZCVDKPXYYASHUUMUJMVSXAD\n" +
                "\n" +
                "GXOYXQFEBFIEJJLHBNGSYALOUXNQBXXZAAZJXENJJVVGFVHOTKSLEGLJVSJCQHSSZFEIOGBOGWSPIRENQAAWRQFBEFEXBKGMSTRC\n" +
                "\n" +
                "PYIANSGMNKBCDPHWDUPKICQEUDNZPNGRUJYSZIRLXGXXITAFBCANGDLVAQLDPVTJNSAUZMBBNOBBOERSHQIOLBVTSPPJKVCMXUBS\n" +
                "\n" +
                "IKMDIYSNCJZKJKJQMTIKEPRUNAHJUSWJHSLWIVWHYAYLOIOGSZVWKQWXZDBPHWZRAIPMXDJHBIISVJWVEVZAEGAKCYYMNZARBZPC\n" +
                "\n" +
                "DLDFVQDFDMVHYVOWEKMFKWUXLTPWIVKPRZZXOLMDAPAIQEKJHCHYAGJDBOFWDGNEGQGOOKWSKLTLREMGGTVJFHAIBCQKNZVRCZYS\n" +
                "\n" +
                "FBQASGNCCBBGNKJHCDBTGBIIWKMPHDABKEWDEPYEAVKNMPATUZZUOEHGUGAZNECSGUCIIJPMMRAMTVADMTCRJCBWDLWWFNFOWMVZ\n" +
                "\n" +
                "XFJFBGDAVGGAIZHAUIYENDZTRUWHPQUFWCHOXNCWYNAWVPLBLNQKQDTKQQKXNFXCTBGRWUZFHNRBDNLNKQVOLLGBBJQIYOBCEIKO\n" +
                "\n" +
                "CURAGWXMLYBSIZLAXFONZZMQMRNNSRQKRHQGFGZUTLONAYRKSSOWAMKZBSGOOYQDPTBHGPBNQEDCZHRTOXREOFJEKJVIZXZBCJPN\n" +
                "\n" +
                "KGYBZTZRKOGBETJRUWRNUCIFKIMCZGYTZLCZYGCGKVZRJIFZQIQPTCPPUHYWIXBOFFGSGSAIMNGKKUUROAVNJUQQNSWJRZIZEHAF\n" +
                "\n" +
                "DDAOBVCPOVODVJFLSNPJXHWQBHILWZAHQQMTQASNADZLZNXJLJMFCOUWOZJCMVVTYCKTUBABWLCEBNYWAMOLNBQQYBRUJCQCZALE\n" +
                "\n" +
                "TVVRPMYFIKINHIUEJBDLTCUMMUWICIUVCZNIQIUEWVAHLANQIAONMEYJWPDAFXVNOSOFDOCESSLGZPTJINBUAFWWWMPTYALZIGVD\n" +
                "\n" +
                "DCZGKILMBFXIQQFEKJBIUDEMIFCANVGNYZAYSQFMNNQFEPZFUUVGTBKSMDXITBLANQIAOQUKTPNYPOWSQQYWWMJHSDYVFDJYXBAF\n" +
                "\n" +
                "VGYXAMDRRZWVIHNQPZZWRNWBTROOJOLNUGXBILZKQEGIQSYGKZGODPWBJSCMRRWSSQURUFIAFQGEZLGZNOEQMNQEYUKPEQPPVAMO\n" +
                "\n" +
                "SYSFUAJFKIPUJVQSZRWQCJYAUMLDDNOKODDXIEQIFLANQIAOZFUNKUBVDBLMJOAUTVCZVLKJRQIORQPGAVCEYVNYUZHXILHERYEC\n" +
                "\n" +
                "GJEKWEKIJNIWUXZNVIWIAANHIOSOLATSQFSSCTAKESUTSPPYFHEHLVLIBJZEEBCOWMNHFTZMAPKFUPNFLTFFJQRVJHAKDVMGGUIX\n" +
                "\n" +
                "KAKXXNKSOAIQNALLWKWGVACYWBQEVTFSEUCYRORQTHWFUJFLQHONWZEKPLSNPRPBOMOFFCPMKXFZBKIERBKDYFKYUEYVYRPMOAQI\n" +
                "\n" +
                "WNICDLQKZXGTKDLIEFBGELGJOAIQNALXZLGGDQIBVEULDPBWUJNTYOKFBPGMAWRRUJPPIGYCNYURNOSQRIRBAZAGWWDUHAAZQWPT\n" +
                "\n" +
                "KFXZQXRMKSBUXWOUVVHSJWTLKZELGXMMAIDSJIWGCJPCBWZIEKMNUPUAFHTUMOZKJWVTIAQNOHELEMWGKJHKPNJVSRVHAUFXBUOU\n" +
                "\n" +
                "XOWCZJYQLXJRUOOYSKDLDXKWTTJBYBTLKSWRUYPOYTPBGUJXBMRWNELBWADCSZDAEEFGPVRHNNLBFDDXNPDXLKQUSJAZDEUDBMBD\n" +
                "\n" +
                "QIKYEKMVUHGGWZDKXFVQQNECZOAWCFUBHQMEPEPKEFSDBAYJQOSGAIHRBRAUKLQRANKMTTIOJDDXAEWTQHIYSGRRMEFTNNWCLZSI\n" +
                "\n" +
                "ZFUQAQCSFNVUQMKUQWBWFQIEQVVXPOSVIDTUOBLLTGHQKEMSUWWHWRISLGRDPPQPZBANSGDWXKNYTKMWECPMPDYSCJZXPUKPWGYI\n" +
                "\n" +
                "CNGVLBSCBHRLJARWSRENGHYYQDKRATERCPEAOPAJZUMOYIDHVPDMQPKKHCBAMRBGEIEXXJALMCXKPUGXYVINRORFYURXAMOJCBZQ\n" +
                "\n" +
                "YJHHAWESCLMDIHVYMLAJZQSYTDEURWYPOLJCAKIKSATGVIALBLWPPKDEGSPMRLDBQNVPPCLQXKUQLQJERMYFGAETUATEBQZUMGUN\n" +
                "\n" +
                "NBWUBVXYDFPLPJYLIDFVTVKKGFWMXVINLJUDUPABTSBJAJENZSXIMUJQWPEZTAVDMBBHFYTJKYFXIXQTBTTQIKQXQDPWYNMXRQDJ\n" +
                "\n" +
                "OGWLZQUBJJHAQNPVRGHGPNMMJPIDGANYEEDWYPOLKLNEPYSRTQYCJLSWFRJRRGGSNSDHIXYYSNAKKBWQDDGYYMOGPUXQEUSAPSOU\n" +
                "\n" +
                "CLLSELRVFZUFYVTJQKCQHNICMERWQFQNPVRPIIYKHZWJYJAFCLNSZXUHSPOZWQUMJHLKKYJENVZOCSWCTPYWIZONUUCLSUROGAYS\n" +
                "\n" +
                "AZGNIMXPLPCEPULRRBHHQOBELHJZPUQAMWUASVKDXVEWAOFMAYSJFXHCNEUXUQWUESFBRUFZQLKKWHCHKOPLECCBYSLECAEZIMMI\n" +
                "\n" +
                "TUUEOCEBAUKWLTSYJJPLZTIARAOZXKYYWIOXBBTZZCSAULKNEJWVQXIKUWBIWVHGNTHVBAWAVPGLHSDJDLPVHHHUNVSFKXARXLVQ\n" +
                "\n" +
                "EMVDFSLANQIAOPTLFLFRKGNUZCTXWCAXHECTZFHWUFENRGQICHTYLSHZWIEGLNVDJZOMTKAAUWOHVOVOCTUKOSINSAYIAEUYORNA\n" +
                "\n" +
                "VGPRMLCAQZIPRFQOZMEFTQZYVOTVFNVOIQSJCIPPQXQKJIXICUIGMHAJJMSXENCBQFIJHNZXIQMWACKDKQSEWWKMLOAUPFHAZGRY\n" +
                "\n" +
                "SQWQMRSQBGGKYKGWEZYRIHWGNXRPOUMFSFGTYDLUDWPWAVQORTMQUXWKUQVNMDPWQFIZPOIHCJATODRQGZDMQXZVNXXVEJNGWZOM\n" +
                "\n" +
                "PVBGZSQPCELDIWDHOQWAUHILGLPYRIICTLFSOYKQZYZOCIZPTECSWOODGGBDTSGIMYGMVPJPRPEVWOOKYFWRGXHWUCRQNYJEMSYL\n" +
                "\n" +
                "XWOFXFVDXPTHYTCEGMODCILAHYBREZVVHOUPZKCNHUEVPMKHUBNRPFMWXVQACVZCALZLYMZSBLCEASPMIEFOTGKMPGWYQADSNDPR\n" +
                "\n" +
                "QPHAVLZDZLKIEISFLLVWXAVBZLZIJRHGROUVGXRDLUJAXNHBBZYNCVERJGSKLWZEKGJBCWMSMLYIHZFFMIOGVIMZQBSRHQWAADYN\n" +
                "\n" +
                "MNXEGTDXCDKIUDOISQXEUJWETPELKBCYFSDNJQWNNBPYMWBUPQBAAINMYZOYCEGNLFNNHZFEMSQVXJJGWBCRAVKZFWFBKMBRVBFD\n" +
                "\n" +
                "HKACSZIUWUXLWKFPKOCUQJEPQDZCMUJFLVCLIOQQRVKSWFIAKNHMRLNJTKGVNTGLCVPVMBLJANOBCXUGVWBJYSIXZQVAVFWILWFB\n" +
                "\n" +
                "QWNLTPMCYHRSKVHXLONRANWKWXUTHYQLIOFKGDBMSWDRCYRKVSAGGRJMWQYQFLMUIGGCLAUQAACTYLPZEOJBHMWRKHCRXGTGRMUP\n" +
                "\n" +
                "CPQKJRBLYDNPUGHCRBVYBAIRVCAWLBWVWCMKNBIRKJOUGYQEBQRHDSTWXDIWGRVMLIJFBWHLHCDAAVUDLZSCGQNOUXVUIVIZZZMD\n" +
                "\n" +
                "NMHGYPFUUDWKQGTAKKGCDFJFYJFNRZVXDPGZEAMWQVQZODKTXHIYFVKJSSAWVHYCUCZMLLBPXTILDYJQEMWDRUFKISOUVPUDTYPB\n" +
                "\n" +
                "FDAQUBXHUJYTAYNWVIJNUSQDTQDEMUAPWXRYUWONTBDZCHZOUEGPMWEZTQWWSHAYOBWVTDIMZYNVNZKUHOFCQKPHJXWNRCGUJEKO\n" +
                "\n" +
                "WSDAUGUTVWCVHEMOIRJJGTANUWTSAIXXEVZTBDHPGSRHHVWCDZVZYRJTLONIJVXEATHQXOUKBIGZONFRSZIOGWNTYAJYLQCGEOWY" ;
         //1. Arrange the string 
        String strAll = str.replaceAll( "\n" , "" );
         //2. Create the corresponding two-dimensional array 
        char [] chars = strAll.toCharArray();   // The string is first converted into a character array 
        char [][] array = new  char [ 100 ][ 100 ];
         int a = 0 ; //array subscript 
        //3, loop to put the string data into the two-dimensional array 
        for ( int i = 0 ; i < array .length; i++) {
            for ( int j = 0 ; j < array [ 0 ].length; j++) {
                 array [i][j] = chars[a]; // store each character in the string into a two-dimensional array
                a++;
            }
        }
        //4. Find a direction and perform breadth-first query LANQIAO (from left to right) 
        for ( int i = 0 ; i < 100 ; i++) {
             for ( int j = 0 ; j < 100 - 6 ; j++) { / /Because the last 6 will definitely not appear in the string 7 combination 
                if ( array [i][j] != 'L' ) { //The first one is not L and exit this loop directly 
                    continue ;
                }

                //The char [] c1 = {   // The 7 characters that store the 7 strings are extracted from j and compared with LANQIAO 
                        array [i][j],
                         array [i][j + 1 ],
                         array [ i][j + 2 ],
                         array [i][j + 3 ],
                         array [i][j + 4 ],
                         array [i][j + 5 ],
                         array [i][j + 6 ]
                };
                //Turn the array into a string 
                String s1 = new String(c1);
                 if (s1.equals( "LANQIAO" )) {
                    count++;
                }

            }
        }
        System.out.println( "Number of times from left to right: " + count);
         //from right to left 
        int count1 = 0 ;
         for ( int i = 0 ; i < 100 ; i++) {
             for ( int j = 99 ; j >= 6 ; j--) {
                 if ( array [i][j] != 'L' ) { // Exit the loop directly if the first bit is not L 
                    continue ;
                }

                //The char [] c2 = {   // The 7 characters that store the 7 strings are extracted from j and compared with LANQIAO 
                        array [i][j],
                         array [i][j - 1 ],
                         array [ i][j - 2 ],
                         array [i][j - 3 ],
                         array [i][j - 4 ],
                         array [i][j - 5 ],
                         array [i][j - 6 ]
                };
                //Turn the array into a string 
                String s2 = new String(c2);
                 if (s2.equals( "LANQIAO" )) {
                    count1++;
                }
            }
        }
        System.out.println( "Number of occurrences from right to left: " + count1);
         //From top to bottom 
        int count7 = 0 ;
         for ( int i = 0 ; i <   94 ; i++) {   //0~94 The last 6 can't make up LANQIAO at all 
            for ( int j = 0 ; j < 100 ; j++) { //0-99 
                if ( array [i][j] != 'L' ) { // first bit is not L Exit this loop directly 
                    continue ;
                }
                char[] c7 = new char[]{
                        array[i][j],
                        array[i + 1][j],
                        array[i + 2][j],
                        array[i + 3][j],
                        array[i + 4][j],
                        array[i + 5][j],
                        array[i + 6][j],
                };
                String s7 = new String(c7);
                if (s7.equals("LANQIAO")) {
                    count7++;
                }
            }
        }
        System.out.println( "Number of times from top to bottom: " + count7);
         //From bottom to top 
        int count8 = 0 ;
         for ( int i = 99 ; i >= 6 ; i--) { //99 ~ 6 
            for ( int j = 0 ; j < 100 ; j++) { //0 ~ 100 
                if ( array [i][j] != 'L' ) {
                     continue ;
                }
                char[] c8 = new char[]{
                        array[i][j],
                        array[i - 1][j],
                        array[i - 2][j],
                        array[i - 3][j],
                        array[i - 4][j],
                        array[i - 5][j],
                        array[i - 6][j],
                };
                String s8 = new String(c8);
                if (s8.equals("LANQIAO")) {
                    count8++;
                }
            }
        }
        System.out.println( "Number of times from bottom to top: " + count8);
         //From top left to bottom right 
        int count3 = 0 ;
         for ( int i = 0 ; i < 94 ; i++) {
             for ( int j = 0 ; j < 94 ; j++) {
                 if ( array [i][j] != 'L' ) { // exit the loop directly if the first bit is not L 
                    continue ;
                }
                char [] c3 = {     // Extract 7 characters from j and compare them with LANQIAO 
                        array [i][j],
                         array [i + 1 ][j + 1 ],
                         array [i + 2 ][j + 2 ],
                         array [i + 3 ][j + 3 ],
                         array [i + 4 ][j + 4 ],
                         array [i + 5 ][j + 5 ],
                         array [i + 6 ][j + 6 ]
                };
                String s3 = new String(c3);
                if (s3.equals("LANQIAO")) {
                    count3++;
                }
            }
        }
        System.out.println( "Number of times from top left to bottom right: " + count3);
         //From bottom left to top right 
        int count4 = 0 ;
         for ( int i = array .length - 1 ; i >= 6 ; i-- ) { //99 ~ 6 
            for ( int j = 0 ; j < array .length - 6 ; j++) { //0 ~ 94 
                if ( array [i][j] != 'L' ) { //first If the bit is not L, exit this loop directly 
                    continue ;
                }
                char[] c4 = new char[]{
                        array[i][j],
                        array[i - 1][j + 1],
                        array[i - 2][j + 2],
                        array[i - 3][j + 3],
                        array[i - 4][j + 4],
                        array[i - 5][j + 5],
                        array[i - 6][j + 6],
                };
                String s4 = new String(c4);
                if (s4.equals("LANQIAO")) {
                    count4++;
                }
            }
        }
        System.out.println( "Number of occurrences from bottom left to top right" + count4);
         //From top right to bottom left 
        int count6 ​​= 0 ;
         for ( int i = 0 ; i < array .length - 6 ; i++) { //0 ~94 
            for ( int j = array .length - 1 ; j >= 6 ; j--) { //99~6 
                if ( array [i][j] != 'L' ) {
                     continue ;
                }
                char[] c6 = new char[]{
                        array[i][j],
                        array[i + 1][j - 1],
                        array[i + 2][j - 2],
                        array[i + 3][j - 3],
                        array[i + 4][j - 4],
                        array[i + 5][j - 5],
                        array[i + 6][j - 6],
                };
                String s6 = new String(c6);
                if (s6.equals("LANQIAO")) {
                    count6++;
                }
            }
        }
        System.out.println( "Number of times from top right to bottom left: " + count6);
         //From bottom right to top left 
        int count5 = 0 ;
         for ( int i = array .length - 1 ; i >= 6 ; i-- ) { //99~6 
            for ( int j = array .length - 1 ; j >= 6 ; j--) {   //99~6 
                if ( array [i][j] != 'L' ) {
                     continue ;
                }
                char[] c5 = new char[]{
                        array[i][j],
                        array[i - 1][j - 1],
                        array[i - 2][j - 2],
                        array[i - 3][j - 3],
                        array[i - 4][j - 4],
                        array[i - 5][j - 5],
                        array[i - 6][j - 6],
                };
                String s5 = new String(c5);
                if (s5.equals("LANQIAO")) {
                    count5++;
                }
            }
        }
        System.out.println( "Number of occurrences from bottom right to top left:" + count5);
    }
}

Note: Figure out how the subscript of each orientation should be represented,

You may also like...

Leave a Reply

Your email address will not be published.