超时,,,
查看原帖
超时,,,
340222
代码练习生楼主2020/7/15 11:18
#include<stdio.h>
#include<stdlib.h>

struct human{
    int flag;
    char pro[11];
    struct human * next,* pre;
};

int
main(){
    struct human * head=NULL,*temp1=NULL,*temp2;
    int n,m,num;
    
    scanf("%d%d",&n,&m);
    head=malloc(sizeof(struct human));
    scanf("%d%s",&head->flag,&head->pro);
    head->next=head->pre=head;
    temp1=head;
    while(--n){
       temp2=malloc(sizeof(struct human));
       scanf("%d%s",&temp2->flag,&temp2->pro);
       head->pre=temp1->next=temp2;
       temp2->next=head;
       temp2->pre=temp1;
       temp1=temp2;
    }
    temp1=head;
    while(m--){
        scanf("%d%d",&n,&num);
        if(n^temp1->flag){
            while(num--){
                temp1=temp1->next;
            }
        }else{
            while(num--){
                temp1=temp1->pre;
            }
        }
    }
    printf("%s",temp1->pro);
    return 0;
}
2020/7/15 11:18
加载中...