[HIHO1039] Character elimination (string, enumeration, impersonation)

Source: Internet
Author: User
Tags fread

Title Link: http://hihocoder.com/problemset/problem/1039

Idea: Enumerate the location of all character updates and the ABC three modification scheme, then simulate the elimination rules, step-by-step to eliminate. Until it cannot be eliminated, update the answer by subtracting the current string length from the original string length. Actually wrote for a long time.

1     /*2 ━━━━━┒ギリギリ♂eye! 3 ┓┏┓┏┓┃キリキリ♂mind! 4 ┛┗┛┗┛┃\0/5 ┓┏┓┏┓┃/6 ┛┗┛┗┛┃ノ)7 ┓┏┓┏┓┃8 ┛┗┛┗┛┃9 ┓┏┓┏┓┃Ten ┛┗┛┗┛┃ One ┓┏┓┏┓┃ A ┛┗┛┗┛┃ - ┓┏┓┏┓┃ - ┃┃┃┃┃┃ the ┻┻┻┻┻┻ - */ -#include <algorithm> -#include <iostream> +#include <iomanip> -#include <cstring> +#include <climits> A#include <complex> at#include <fstream> -#include <cassert> -#include <cstdio> -#include <bitset> -#include <vector> -#include <deque> in#include <queue> -#include <stack> to#include <ctime> +#include <Set> -#include <map> the#include <cmath> * using namespacestd; $ #defineFr FirstPanax Notoginseng #defineSC Second - #defineCL Clear the #defineBUG puts ("Here!!!") + #defineW (a) while (a--) A #definePB (a) push_back (a) the #defineRint (a) scanf ("%d", &a) + #defineRll (a) scanf ("%lld", &a) - #defineRs (a) scanf ("%s", a) $ #defineCIN (a) CIN >> a $ #defineFRead () freopen ("in", "R", stdin) - #defineFWrite () freopen ("Out", "w", stdout) - #defineRep (i, Len) for (int i = 0; i < (len); i++) the #defineFor (I, A, Len) for (int i = (a); I < (len); i++) - #defineCls (a) memset ((a), 0, sizeof (a))Wuyi #defineCLR (A, X) memset ((a), (x), sizeof (a)) the #defineFull (a) memset ((a), 0x7f7f7f, sizeof (a)) - #defineLRT RT << 1 Wu #defineRRT RT << 1 | 1 - #definePi 3.14159265359 About #defineRT return $ #defineLowbit (x) x & (-X) - #defineOnenum (x) __builtin_popcount (x) -typedefLong LongLL; -typedefLong DoubleLD; Atypedef unsignedLong LongULL; +typedef pair<int,int>PII; thetypedef pair<string,int>psi; -typedef PAIR&LT;LL, Ll>PLL; $typedef map<string,int>MSI; thetypedef vector<int>VI; thetypedef vector<ll>VL; thetypedef vector<vl>VVL; thetypedef vector<BOOL>vb; -  in Const intMAXN = the; the strings, T, F; the BOOLVIS[MAXN]; About intN, M, K; the intret; the  the intCheckintPCharc) { + t.cl (); f.cl (); -     if(p = =0) { the T.PB (c);Bayi Rep (i, N) t.pb (s[i]); the     } the     Else if(p = =N) { -t =s; - T.PB (c); the     } the     Else { the Rep (i, p) T.PB (S[i]); the T.PB (c); - For (i, p, N) T.PB (s[i]); the     } the      while(1) { the         BOOLExflag =1;94m =t.length (); the f.cl (); Cls (VIS); theRep (i, M-1) { the             if(T[i] = = t[i+1]) {98Vis[i] =1; Aboutvis[i+1] =1; -Exflag =0;101             }102         }103 Rep (i, m) {104             if(!Vis[i]) { the F.PB (T[i]);106             }107         }108t =F;109         if(Exflag) Break; the     }111     returnn +1-m; the }113  the intMain () { the     //FRead (); the     intT;117 Rint (T);118 W (T) {119CIN >>s; -n =s.length ();121RET =0;122for (I,0, n+1) {123RET = max (ret, check (i,'A'));124RET = max (ret, check (i,'B')); theRET = max (ret, check (i,'C'));126         }127printf"%d\n", ret); -     }129Rt0; the}

[HIHO1039] Character elimination (string, enumeration, impersonation)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.