Little Brick's Dream

mail@pastecode.io avatar
unknown
c_cpp
2 years ago
986 B
2
Indexable
Never
//Little Brick's Dream 

#include <stdio.h>
#define MAX 10005

int main(){

    int n, x, found = 0, index = 0;
    int line[MAX], level[MAX], ans[MAX];
    scanf("%d%d%d", &n, &x, &line[0]);
    level[0] = 0;
    for(int i = 1; i < n; i++){
        scanf("%d", &line[i]);
        if(line[i] == line[i-1]) level[i] = level[i-1];
        else if(line[i] < line[i-1]) level[i] = 0;
        else{
            for(int j = i-1; j >= 0; j--){
                if(line[i] > line[j]){
                    level[i] += level[j]+1;
                    j = j-level[j];
                }
                else break;
            }
        }
        if(level[i] == x){
            ans[index] = i;
            found = 1, index++;
        }
    }
    if(found == 0) printf("ouo\n");
    else{
        for(int i = 0; i < index; i++){
            if(i != index-1) printf("%d ", ans[i]+1);
            else printf("%d", ans[i]+1);
        }
        printf("\n");
    }
}