Did you know that you can use domino bones for other things besides playing Dominoes? Take a number of dominoes and build a row by standing them on end with only a small distance in between. If you do it right, you can tip the first domino and cause all others to fall down in succession (this is where the phrase “domino effect” comes from).
啥都不用说了..原来我想出来的算法 在五十年前已经被一名叫做的Dijkstra同学提出来了.. 恨啊 晚生半个世纪
Dijkstra’s algorithm传送门
http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm
右边图示很销魂
前面都差不多就是当结果是between a and b时需要技巧,我是在所有dominoes都倒下后将所有连接的节点进行计算,多米诺卡在ab之间的时间等于(a.time+b.time+ab之间时间)/2,当b是由a推倒时,这个数值就等于b的时间,不可能超过最长时间,因而无需额外考虑,方便啊!
[c]#include <cstdio>
#include <cstring>
#define MAXNUM 500
typedef struct card{
int time;
int l[MAXNUM+1];
bool touched,out;
} Card;
int n,p,p1=-1,p2;
float time;
Card a[MAXNUM+1];
void dij();
void between();
int main() {
int c,b,l,m;
int i,N=1;
Card ini; //used to initialize
memset(ini.l,-1,sizeof(int)*(MAXNUM+1));
ini.time=0;
ini.touched=false;
ini.out=false;
scanf("%d%d",&n,&m);
while(n!=0) {
for(i=1;i<=MAXNUM;i++)
a[i]=ini;
p1=-1;
time=0;
for(i=0;i<m;i++) {
scanf("%d%d%d",&c,&b,&l);
a[c].l[b]=a[b].l[c]=l;
}
a[1].touched=true;
for(i=1;i<=n;i++)
dij();
between();
printf("System #%d\nThe last domino falls after %.1f seconds, ",N,time);
if(p1!=-1)
printf("between key dominoes %d and %d.\n\n",p1,p2);
else
printf("at key domino %d.\n\n",p);
N++;
scanf("%d%d",&n,&m);
}
return 0;
}
void dij() {
int i,j,reachtime;
p=-1;
for(i=1;i<=n;i++) {
if(!a[i].touched||a[i].out)
continue;
if(p==-1||a[p].time>a[i].time)
p=i;
}
for(i=1;i<=n;i++) {
if(a[p].l[i]==-1||a[i].out)
continue;
reachtime=a[p].time+a[p].l[i];
if(!a[i].touched||a[i].time>reachtime) {
a[i].time=reachtime;
a[i].touched=true;
}
}
a[p].out=true;
time=a[p].time;
}
void between() {
int i,j;
float t;
for(i=1;i<=n;i++)
for(j=i;j<=n;j++) {
if(a[i].l[j]==-1||(t=(float)(a[i].time+a[j].time+a[i].l[j])/2)<=time)
continue;
p1=i;
p2=j;
time=t;
}
}[/c]
References:
KingMaker mindesteinzahlung es.yoo7.com
References:
Monro Casino PayPal fmodpro.com
References:
Hitnspin login ntedles.yoo7.com
References:
Hitnspin verifizierung http://researchesanswered.akamaized.net/
References:
Monro Casino Kundenservice http://images.google.ru/
References:
Hit n spin casino deutsch mong.jw.lt
References:
Hit spin casino http://conny-grote.de
References:
Hitnspin casino mit echtgeld http://fahrschule-stuwe-tuebingen.de/htsrv/login.php?redirect_to=https://board-en.farmerama.com:443/proxy.php?link=https://de.trustpilot.com/review/der-wikinger-shop.de
References:
Hitnspin casino zahlungsmethoden https://adultonlywebcams.chaturbate.com/
References:
Hitnspin casino sign up bonus http://dreamwar.ru/redirect.php?https://intensedebate.com/people/blackpolice3
References:
Hitnspin casino auszahlungslimit https://cm.lesta.ru/frame/?backend_url=//bit.ly/opsuimolog5012&content_layout_max_width=1335&language=ru&login_url=https://www.lanubedocente.21.edu.ar/profile/hawkinszkmbowen16952/profile
References:
Hitnspin bonus ohne einzahlung kpbc.umk.pl
References:
Hit n spin casino login embed.gosugamers.net
References:
Hitnspin casino spielautomaten https://wiki.opencellid.org/
References:
Hitnspin casino bonus code https://discuss.7msport.com
References:
Hitnspin casino sign up bonus https://yandex.com.am/
References:
Hitnspin casino freispiele https://fsin-russia.ru
References:
Hitnspin casino legal thumbnails.porncore.net
References:
Hitnspin casino promo code board-en.piratestorm.com
References:
Hitnspin casino spielautomaten https://mcpedl.com/leaving/?url=http://atavi.com/share/xvvexqz1pfhmd
References:
Hit n spin no deposit bonus bbs.pinggu.org
References:
Lollybet Casino No Deposit Bonus https://vocab.getty.edu/resource?uri=http%3A%2F%2Fastrakhanica-personalia.ru%2Fapi.php%3Faction%3Dhttps%3A%2F%2Flollybet.com.de%2F
References:
Lollybet Casino Test https://sculptandpaint.com/proxy.php?link=https://board-de.farmerama.com:443/proxy.php?link=https://lollybet.com.de/
References:
Lollybet Meinung http://cse.google.tm/url?q=http%3A%2F%2Fskyscrapperwiki.site%2Fwiki%2FBonus_215_1_000_100_Freispiele
References:
Lollybet Deutschland http://clients1.google.com.cy/url?q=https://neolatinswiki.site/wiki/LollyBet_Rezension_Bewertungen_von_echten_Spielern_2026
References:
Lollybet Slots https://almanach.pte.hu/oktato/273?from=http://hci.cs.umanitoba.ca/?URL=https://lollybet.com.de/
References:
Lollybet Cashback http://shop.litlib.net/go/?go=http%3A%2F%2Falt1.toolbarqueries.google.com.nf%2Furl%3Fq%3Dhttps%3A%2F%2Flollybet.com.de%2F
References:
Lollybet Casino Live Dealer https://preserve.lib.unb.ca/wayback/20141205151334mp_/https://molchanovonews.ru/user/bassliquid5/
References:
Lollybet legal http://www.google.tt/url?q=https://freerepublic.com/~voyagesechellesluxe/index?U=https%3A%2F%2Flollybet.com.de
References:
Lollybet Bonus Code https://www.paltalk.com/linkcheck?url=ztube.com.br%2F%40cristineyokoya%3Fpage%3Dabout
References:
Lollybet Casino http://alginis.yoo7.com/go/aHR0cHM6Ly93d3cuY2hlbWJhbnMuY29tL0BvdXh0YXlsYWg3MDk1
References:
Hitnspin casino auszahlung erfahrungen http://cse.google.by/url?sa=t&url=http://qa.doujiju.com/index.php?qa=user&qa_1=doubtsister8
References:
Hitnspin casino mit echtgeld http://ar.thefreedictionary.com/_/cite.aspx?url=https://skyscrapperwiki.site/wiki/Offizielle_Seite_HitnSpin_Casino_in_Deutschland&word=%D8%AD%D9%8E%D9%84%D9%90%D9%85%D9%8E&sources=kdict
References:
Hitnspin casino sicher http://59ga.ru/go/url=-aHR0cHM6Ly90ZWxlZ3JhLnBoL0hpdG5zcGluLUNhc2luby1PbmxpbmUtRGV1dHNjaGxhbmQtQm9uaS1GcmVpc3BpZWxlLU1vYmlsZS1BcHAtTG9naW4tMDYtMDctMg===
References:
Hit’n’spin casino 25 euro bonus ohne einzahlung http://cgi.davec.plus.com/cgi-bin/logs/loglink.cgi?https://flashjournal.site/item/spielen-gewinnen
References:
Hitnspin willkommensbonus http://clients1.google.tn/url?q=https://www.holycrossconvent.edu.na/profile/hendrixflymahmoud90141/profile
References:
Hit n spin casino promo code http://aktsh.ru/go.php?url=https://www.orkhonschool.edu.mn/profile/blockmsavestergaard99433/profile
References:
Hitnspin verifizierung http://clients1.google.com.af/url?q=https://www.haphong.edu.vn/profile/mccluresxmlillelund65483/profile
References:
Hitnspin casino willkommensbonus http://ezproxy.lib.uh.edu/Login?url=https://headlinelog.site/item/beste-online-casinos-2026-top-10-anbieter-f-r-deutsche-spieler
References:
Casino hitnspin http://karanova.ru/?goto=http://downarchive.org/user/peacequit5/
References:
Hit n spin casino bonus code http://images.google.bg/url?q=https://ryu-ga-index.com:443/index.php?napiersnyder362362
References:
Hitnspin casino ohne anmeldung http://cse.google.cm/url?q=http://web.symbol.rs/forum/member.php?action=profile&uid=1334465
References:
Hitnspin casino spiele http://chat.chat.ru/redirectwarn?https://zenwriting.net/stewsyrup0/bonus-800-300-freispiele
References:
Hit n spin casino online login http://m.animal.memozee.com/m.list.php?q=%3Ca%20href=%22https://medibang.com/author/28613409/
References:
Hit n spin bewertung http://clients1.google.com.af/url?q=https://hedgedoc.eclair.ec-lyon.fr/s/WO3L4D7Plw
References:
Australian pokies payid https://gitea.accept.dev.dbf.nl/josettecontrer
References:
Instant payid pokies australia https://www.atlantistechnical.com/employer/how-to-create-a-payid/
References:
Lollybet Casino Bonus https://www.omicsonline.org/recommend-to-librarian.php?title=Phobias%7CAnxietydisorder%7CSocialphobia%7CAgoraphobia&url=https://upangmarga.go.id/edisonfollmer
References:
Lollybet Casino Bonus ohne Einzahlung http://alt1.toolbarqueries.google.com.nf/url?q=https://link.epicalorie.shop/carymarkham990
References:
Lollybet Casino Gutschein http://toolbarqueries.google.ms/url?q=https://lnk.rexanhotels.com/quincylerner8