CF Codeforces Round #162 (Div. 1) A. Escape from Stones

http://codeforces.com/problemset/problem/264/A

DIV2的C题,话说做了一个小时就回宿舍了,结果还是被楼管阿姨锁在了外边,无语啊。。

就是一个简单的双向链表...模拟插入。 但是只是想着算出1/2 1/4 ...来然后排序,(1/2)^(10^6)啊,不吵数据类型才怪呢。。无语啊。。

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#define CL(a,num) memset((a),(num),sizeof(a))
#define iabs(x)  ((x) > 0 ? (x) : -(x))
#define Min(a,b) (a) > (b)? (b):(a)
#define Max(a,b) (a) > (b)? (a):(b)

#define ll __int64
#define inf 0x7f7f7f7f
#define MOD 1073741824
#define lc l,m,rt<<1
#define rc m + 1,r,rt<<1|1
#define pi acos(-1.0)
#define test puts("<------------------->")
#define maxn 100007
#define M 20007
#define N 1000007
using namespace std;
//freopen("din.txt","r",stdin);

struct node
{
    int id;
    node *next,*pre;
}*head,*end,*cur;

char s[N];

int main()
{
     scanf("%s",s);
     head = new node;
     end = new node;
     cur = new node;

     head->next = end;
     end->pre = head;
     cur = head;
     end->next = NULL;
     int len = strlen(s);
     for (int i = 0; i < len; ++i)
     {
         node *p = new node();
         p->id = i + 1;
         p->next = cur->next;
         cur->next = p;
         p->pre = cur;
         cur->next->pre = p;
         if (s[i] == 'r') cur = cur->next;
     }
     node *q = new node();
     for (q = head->next; q != end; q = q->next)  printf("%d\n",q->id);
     return 0;
}

  

 

你可能感兴趣的:(CF Codeforces Round #162 (Div. 1) A. Escape from Stones)