Skip to content

Instantly share code, notes, and snippets.

@nebuta
Last active January 3, 2016 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nebuta/8487453 to your computer and use it in GitHub Desktop.
Save nebuta/8487453 to your computer and use it in GitHub Desktop.
Is (´・_・`((´・_・`)´・_・`)) a copy-and-paste of (´・_・`)?
#include <vector>
#include <iostream>
using namespace std;
bool failed = false;
int pos = 0;
string s;
string seq = "ABCDCba";
void sub(){
//printf("%d\n",pos);
if(s[pos] != seq[0]){
//printf("failed at %d\n",pos);
failed = true;
return;
}
int c, accum = 0;
pos++;
for(int c = 1; c < 7;){
if(s[pos+accum] == seq[0]){
pos += accum;
accum = 0;
sub();
}else{
if(s[pos+accum] == seq[c]){
c++;
accum++;
//printf("%d\n",accum);
}else{
failed = true;
//printf("failed at (%d,%d)\n",pos,c);
return;
}
}
}
pos += accum;
//printf("%d\n",pos);
}
bool run() {
int len = s.length();
//printf("%d\n",len);
do{
sub();
//printf("After sub(): %d\n",pos);
}while(pos < len-1 && !failed);
return !failed;
}
int main(){
cin >> s;
bool r = run();
if(r){
puts("YES");
}else{
puts("NO");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment