Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<string.h>
- char codecube[10] = {"codecube"};
- char str[100010];
- int len;
- int cost(int I,int J){
- int c = 0;
- int ci = 0;
- for(int i = I ; i <= J && ci < 8 ; i ++){
- if(str[i] == codecube[ci]){
- ci++;
- }else{
- c++;
- }
- }
- return (ci == 8 ? c : 1e9);
- }
- int main(){
- scanf("%s",str);
- len = strlen(str);
- int anscost = 1e9;
- int ansI,ansJ;
- for(int i = 0 ; i < len - 7 ; i ++ ){
- for(int j = i + 7 ; j < len ; j ++){
- int tcost = cost(i,j);
- if(tcost < anscost){
- anscost = tcost;
- ansI = i;
- ansJ = j;
- }
- }
- }
- if(anscost == 1e9){
- printf("-1");
- return 0;
- }
- printf("%d %d",ansI+1,ansJ+1);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement