Atcoder Grand Contest 037A (greedy, thinking)

#include <bits / STDC ++ H.>
the using namespace STD;
String S;
char ANS [200007] [. 7];
char ANSS [200007] [. 7];
int main () {
CIN >> S;
int = n-s.size ();
int STA = 0;
int = CNT. 1;
int In Flag = 0;
ANS [CNT] [0] = S [0];
// dividing a character string into two characters, one character, two character. . .
// because the number of characters before and after different, so certainly not the same. If this is not the same as a character and on, it is divided into a character, a character, a character. . .
for (int I =. 1; I <n-; I ++) {
IF (S [STA] == S [I] && In Flag == 0) {// When this character as a time before and
if (i + 1 < n) {// If there is behind the characters, the characters put on a period of the two
CNT ++;
in Flag =. 1;
I ++;
ANS [CNT] [0] = S [-I. 1];
ANS [CNT] [. 1] S = [I];
}
the else IF (I ==. 1) // If no characters back, put the combined character and the preceding paragraph, the current character does not face, to merge and a character, this time period will be less , for example, AA = S
cnt--;
}
else if(s[sta]!=s[i]&&flag==0){
cnt++;
sta=i;
ans[cnt][0]=s[i];
}
else if(flag==1){
cnt++;
sta=i;
flag=0;
ans[cnt][0]=s[i];
}
}
cout<<cnt;
return 0;
}

Guess you like

Origin www.cnblogs.com/ldudxy/p/11371490.html