hiho week 108 register

Ended

Participants:295

Verdict:Accepted
Score:100 / 100
Submitted:2016-07-24 21:22:45

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <cstdio>
#include <cstring>
struct block{
    int key;
    int len;
    int w;
    block *prev,*next; 
    block(int k,int l){
        key=k;len=l;
        prev=next=NULL;
    }
};
typedef block* node;
node pos[2002];
block *top,*tail;
int n,m; 
void init(){
    top=new block(-1,0);
    block *p=new block(0,m);
    p->prev=top;
    top->next=p;
    tail=new block(-1,0);
    p->next=tail;
    tail->prev=p;
}
block* findempty(int len){
    tail=top->next;
    while(tail->key!=-1){
        if(!tail->key&&tail->len>=len)
            return tail;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX