#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 2000001
//????????????£????????????
struct Node{
  int key;
  struct Node *next,*prev;
};
 
struct Node *nil;
 
struct Node* listSearch(int key){
  struct Node *cur=nil->next;
  while(cur!=nil&&cur->key!=key){
    cur=cur->next;
  }
  return cur;
}
 
void init(){
  nil=(struct Node *)malloc(sizeof(struct Node));
  nil->next=nil;
  nil->prev=nil;
}
 
void output(){
  struct Node *cur=nil->next;
  int i=0;
  while(1){
    if(cur==nil) break;
    if(i++>0) printf(" ");
    printf("%d",cur->key);
    cur=cur->next;
    }
  printf("\n");
}
 
void delNode(struct Node *t){
  if(t==nil) return;
  t->prev->next=t->next;
  t->next->prev=t->prev;
  free(t);
}
 
void delF(){
  delNode(nil->next);
}
 
void delL(){
  delNode(nil->prev);
}
 
void delKey(int key){
  delNode(listSearch(key));
}
 
void insert(int key){
  struct Node *a=(struct Node *)malloc(sizeof(struct Node));
  a->key=key;
  a->next=nil->next;
  nil->next->prev=a;
  nil->next=a;
  a->prev=nil;
}
 
int main(){
  int n,key,i,j,npoi=0,ndel=0,size=0;
  char c[12];
 
  scanf("%d",&n);
 
  init();
  for(i=0;i<n;i++){
    scanf("%s %d",c,&key);
 
    if(c[0]=='i'){
      insert(key);
      npoi++;
      size++;
    }
    else if(c[0]=='d'){
if(strlen(c)>6){
      if(c[6]=='F') delF();
      else if(c[6]=='L') delL();
    } else {
        delKey(key);
        ndel++;
      }
        size--;
      }
    }
    output();
  return 0;
}
Compile Error Logs:
You are not authorized to see the message.

Status
Judge: 10/10 	C 	CPU: 00.33 sec 	Memory: 31788 KB 	Length: 1477 B 	2017-07-23 10:54 	2017-07-23 10:54
Results for testcases
Case # 	Verdict 	CPU Time 	Memory 	In 	Out 	Case Name
Case #1: 	: Accepted 	00.00 sec 	600 KB 	88 B 	2 B 	01.in
Case #2: 	: Accepted 	00.00 sec 	600 KB 	203 B 	10 B 	02.in
Case #3: 	: Accepted 	00.00 sec 	600 KB 	375 B 	10 B 	03.in
Case #4: 	: Accepted 	00.00 sec 	600 KB 	105 B 	23 B 	04.in
Case #5: 	: Accepted 	00.00 sec 	600 KB 	643 B 	58 B 	05.in
Case #6: 	: Accepted 	00.00 sec 	596 KB 	52 B 	2 B 	06.in
Case #7: 	: Accepted 	00.00 sec 	596 KB 	1058 B 	110 B 	07.in
Case #8: 	: Accepted 	00.00 sec 	600 KB 	1031 B 	116 B 	08.in
Case #9: 	: Accepted 	00.33 sec 	600 KB 	22392494 B 	5 B 	09.in
Case #10: 	: Accepted 	00.32 sec 	31788 KB 	25527813 B 	1288799 B 	10.in
< prev | 	1 	/ 	10 	| next > 	  		 : Accepted        00.00 sec        600 KB
 
Judge Input #1 ( in1.txt | 88 B) 		Judge Output #1 ( out1.txt | 2 B)

9
insert 5
insert 2
insert 3
insert 1
delete 3
insert 6
delete 5
deleteFirst
deleteLast

		

1

Comments
 
 Under Construction.
 
Categories
 
 
Free Tags
 
 