47 lines
954 B
C
47 lines
954 B
C
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <stdbool.h>
|
|
|
|
bool isBoom(char* stack, char* boom, int top, int lenB);
|
|
void printStack(char* stack, int top);
|
|
|
|
int main() {
|
|
char str[1000001];
|
|
char stack[1000001];
|
|
char boom[36];
|
|
int top = -1;
|
|
|
|
scanf("%s",str);
|
|
int len = strlen(str);
|
|
scanf("%s",boom);
|
|
int lenB = strlen(boom);
|
|
|
|
for (int i = 0; i < len; i++) {
|
|
stack[++top] = str[i];
|
|
if (top + 1 >= lenB && isBoom(stack, boom, top, lenB)) {
|
|
top -= lenB;
|
|
}
|
|
}
|
|
|
|
printStack(stack, top);
|
|
|
|
return 0;
|
|
}
|
|
|
|
bool isBoom(char* stack, char* boom, int top, int lenB) {
|
|
for (int i=0; i<lenB; i++) {
|
|
if (stack[top-lenB+i+1] != boom[i]) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
void printStack(char* stack, int top) {
|
|
if (top == -1) printf("FRULA\n");
|
|
else {
|
|
for (int i=0; i<=top; i++) printf("%c", stack[i]);
|
|
printf("\n");
|
|
}
|
|
} |