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:
Lollybet Casino Sicherheit http://maps.google.nu/url?q=https://imgo.cc/cooperreiniger
References:
Lollybet Casino Promo Code https://cse.google.vg/url?sa=t&url=https://resvoice.com/vzeemmett35739
References:
Lollybet Casino Willkommensbonus google.is
References:
Lollybet Casino Login http://images.google.com.na
References:
Lollybet Auszahlung https://lawsociety-barreau.nb.ca
References:
Lollybet Casino Blackjack maps.google.vg
References:
Lollybet Login http://image.google.co.je
References:
Lollybet Casino Auszahlungsdauer http://maps.google.com/
References:
Lollybet Support http://clients1.google.co.ug/
References:
Lollybet Gutschein captcha.2gis.ru
References:
Lollybet Casino Erfahrungen https://mvsadnik.ru
References:
Lollybet Casino No Deposit Bonus https://wiki.tlib.ru/api.php?action=https://urluno.com/gildacalder155
References:
Lollybet Casino Login 94.cholteth.com
References:
Lollybet Bonus https://foodmarkets.ru
References:
Lollybet Casino Spielautomaten toolbarqueries.google.mn
References:
Lollybet Registrierung shop2.chuukr.cafe24.com
References:
Lollybet APK http://cse.google.cz
References:
Lollybet Erfahrungen http://www.google.pn/url?q=https://biotap.io/bretringrose1
References:
Lollybet Casino Lizenz yandex.ru
References:
Casino grand hirings.online
References:
Casino palm springs https://bookmyaccountant.co/profile/michellergz825
References:
Online casino australia sellyourcnc.com
References:
Casino pennsylvania https://werkstraat.com/
References:
Roulette francese https://trabajaensanjuan.com
References:
Bangor casino https://rabota.balletopedia.ru/companies/instant-casino-bewertung-2026-lohnt-sich-die-anmeldung-wirklich-️-juni-2026/
References:
Thunderstruck drinking game houseofmercycommunityuk.org
References:
Casino barcelona online https://ipcollabs.com
References:
Sugarhouse casino workbay.online
References:
Lollybet Casino Blackjack maps.google.com.sg
References:
Lollybet Casino Erfahrungen embed.gosugamers.net
Good day! I could have sworn I’ve been to this blog before but after browsing through some of the
articles I realized it’s new to me. Nonetheless, I’m definitely pleased I discovered it and
I’ll be book-marking it and checking back frequently!
References:
comic-rocket.com
References:
Lollybet Casino Registrierung http://s0565755c.fastvps-server.com/api.php?action=https://www.jobindustrie.ma/companies/deine-online-spielothek/
References:
Lollybet Meinung http://images.google.dm/url?q=https://healthjobslounge.com/employer/deine-online-spielothek/
References:
Lollybet Casino 100 Freispiele http://maps.google.co.kr
References:
Lollybet Kundenservice google.co.ve
References:
Lollybet Casino 100 Freispiele https://www.gitaristam.ru/
References:
Lollybet Casino Treueprogramm upkbis.ru
References:
Lollybet Casino Verifizierung alagard.ru