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:
Circus Circus Casino Las Vegas Spielhalle Wiesbaden
References:
Paddy power live casino jobshop24.com
References:
Legiano Casino Verifizierung https://anon.to/?https://bybio.co/deenagolde
References:
Legiano Casino Meinungen http://alginis.yoo7.com
References:
Legiano Casino Willkommensbonus http://www.smartphone.ua/
References:
Legiano Casino Live Chat http://maps.google.bt/
References:
Legiano Casino Live Chat http://nou-rau.uem.br/nou-rau/zeus/auth.php?back=https://esbt74.ru/bitrix/rk.php?goto=https://de.trustpilot.com/review/der-wikinger-shop.de&go=x&code=x&unit=x
References:
Legiano Casino Willkommensbonus https://masteram.us/
References:
Ligiano Casino http://toolbarqueries.google.com.ai/
References:
Leggiano Casino https://forums-archive.eveonline.com/warning/?l=https://www.google.vg/url?sa=t&url=https://de.trustpilot.com/review/beyondjewellery.dehttps://forums-archive.eveonline.com/warning/?l=https://www.google.vg/url?sa=t&url=https://de.trustpilot.com/review/beyondjewellery.de</a
References:
Legiano Casino legal https://comita.spb.ru/bitrix/click.php?goto=https://www.sjsu.edu/faculty/beyersdorf/ARPhysics/moduleInfo.php?source=https://de.trustpilot.com/review/beyondjewellery.de
References:
Legiano Casino Verifizierung http://cse.google.cat/url?sa=i&url=https://edufuture.biz/api.php?action=https://de.trustpilot.com/review/beyondjewellery.de
References:
Legiano Casino VIP Programm https://api.follow.it/
References:
Legiano Casino PayPal http://acronyms.thefreedictionary.com
References:
Legiano Casinio https://faktor-info.ru/
References:
Legiano Casino Auszahlungsdauer https://95.cholteth.com/
References:
Legiano Casino VIP Programm https://forum.corvusbelli.com
References:
Ligiano Casino 0845.boo.jp
References:
KingMaker paypal einzahlung https://qr.dsd.edu.gh/
References:
KingMaker einzahlung 10 euro watchnow.site
References:
Kingmaker casino bonus code einzahlung qr-th.com
References:
KingMaker app echtgeld mssq.me
References:
KingMaker jetzt einzahlen bonus http://cse.google.com.cy
References:
KingMaker Casino Einzahlung per Klarna https://api.follow.it/redirect-to-url?q=https://de.trustpilot.com/review/beyondjewellery.de
References:
KingMaker anmelden einzahlung bonus google.co.ao
References:
Kingmaker casino echtgeld einzahlen http://cse.google.co.ao/url?sa=t&url=http://de.trustpilot.com/review/beyondjewellery.de
References:
KingMaker einzahlung bonus code maps.google.com.lb
References:
KingMaker Casino Reload Bonus images.google.com.jm
References:
Legiano Casino Auszahlung maps.google.com.om
References:
Legiano Casino Lizenz http://www.google.ht
References:
Legiano Casino Einzahlung cse.google.kz
References:
KingMaker Casino 10 Euro einzahlen http://maps.google.com.sg/url?sa=t&url=https://301.tv/clarkdebavay95
References:
Kingmaker Casino Einzahlung toolbarqueries.google.ps
References:
KingMaker Casino Krypto Einzahlung http://maps.google.com.uy/
References:
Legiano Casino Verifizierung clients1.google.com.ai
References:
KingMaker konto eröffnen http://images.google.hr/url?sa=t&url=https://linknest.vip/gerardduggan20
References:
KingMaker einzahlung bankkarte xtgem.com
References:
Ligiano Casino https://www.douban.com
References:
Legiano Casino VIP http://www.google.tk
References:
KingMaker Casino Einzahlung mit Google Pay google.com.tw
References:
KingMaker Casino 20 Euro Einzahlung clients1.google.bj
References:
KingMaker einzahlung http://www.google.cf
References:
KingMaker Casino Sofortüberweisung http://www.google.com.ai/
References:
Legiano Casino Mobile maps.google.lk
References:
Legiano Casino Freispiele http://www.google.mg/
References:
Legiano Casino Auszahlung Dauer http://www.google.com.tj
References:
Legiano Casino Mindestauszahlung http://cse.google.gy/
References:
Legiano Casino Download gazmap.ru
References:
Legiano Casino Cashback https://perevodvsem.ru
References:
Legiano Casino Einzahlung http://clients1.google.sr