CodeForces 264A Escape from Stones dfs

2015-07-20 17:14:40 · 作者: · 浏览: 4

题目链接:点击打开链接

题意:开始有一个区间[0,1]

每次操作在中间填i,然后选择坐半段或者右半段(给出选择的方案,然后从左到右输出填写的i)

(i=1 2 3???)



#include 
  
   
char s[1000005];
void dfs(int x){
    if(s[x] == 0)return ;
    if(s[x] == 'l')
    {
    dfs(x+1);
    printf("%d\n", x+1);
    }
    else {
    printf("%d\n", x+1);
    dfs(x+1);
    }
    }
int main(){
    scanf("%s", s);
    dfs(0);
    return 0;
}