您的位置:首页 > 其它

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

2013-01-21 11:12 501 查看
http://codeforces.com/problemset/problem/264/A

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

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

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <List>
#include <set>
#include <map>
#include <string>

#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
;

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;
}


  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: