Coder Social home page Coder Social logo

data_structure's People

Contributors

destroy314 avatar oldmemory1 avatar

Stargazers

 avatar  avatar

Watchers

James Cloos avatar  avatar

Forkers

oldmemory1

data_structure's Issues

2-2综教楼后的那个坑,在devC++编译器里面,会报错,自己改了一下

大概理清那道题的思路了,判断平面数目是否为1那部分,goto语句到最后的last中间有个定义的node* target,devc++因为这个不给编译通过,但是改成这样就可以通过:
#include <stdio.h>
#include <stdlib.h>
typedef struct NODE{
int w,h;
int index;//平面的编号
struct NODE *next;
struct NODE *previous;
}node;
long long int ans[100000];

int main(){
int N;
scanf("%d",&N);
node head;
head=(node
)malloc(sizeof(node));
head->h=1000001;
node *tail=head,*start=head;
for(int i=0;i<N;i++){
node t;
t=(node
)malloc(sizeof(node));
tail->next=t;
scanf("%d %d",&t->w,&t->h);
t->index=i;
t->previous=tail;
if(t->hh){start=t;}
tail=t;
}
node t;
t=(node
)malloc(sizeof(node));
t->h=1000001;
t->previous=tail;
tail->next=t;
long long int time=0;
node *increase=start;//水量增加的平面
if(N==1){//goto last;
ans[increase->index]=time+increase->w;}
while(N!=1){
while(increase->h>increase->previous->h){
increase=increase->previous;
}
while(increase->h>increase->next->h){
increase=increase->next;
}

	    node *target=increase;//水量增加的目标平面
	
    if(target->previous->h>target->next->h){
        target=target->next;
    }
    else{
        target=target->previous;
    }
    time+=increase->w;
    ans[increase->index]=time;
    time+=increase->w*(target->h-increase->h-1);
    increase->previous->next=increase->next;
    increase->next->previous=increase->previous;
    target->w+=increase->w;
    increase=target;
    if(increase->previous->h==increase->next->h){
        //last:;
        ans[increase->index]=time+increase->w;
        break;
    }
}
for(int i=0;i<N;i++){
    printf("%lld\n",ans[i]);
}
return 0;

}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.