The holy topic of human being,love,appears now.Firstly,I'd like to introduce a love song cited from <>
to you as follows.
The Woman
Your lips cover me with kisses;
your love is better than wine.
There is a fragrance about you;
the sound of your name recalls it.
No woman could help loving you.
Take me with you,and we'll run away.
be my king and take me to your room.
We will be happy together,
drink deep,and lose ourselves in love.
No wonder all women love you.
Women of Jerusalem,I am dark but beautiful,
dark as the desert tents of Kedar,
but beautiful as the curtains in Soloman's palace.
Don't look down on me because of my colour,
because the sun has tanned me.
My brotherw were angry with me
and made me work in the vineyard.
I had no time to care for myself.
Tell me,my love,
Where will you lead your flock to graze?
Where will they rest from the noonday sun?
Why should I need to look for you
among the flocks of the other shepherds?
The Man
Don't you know the place,loveliest of women?
Go and follow the flock;
find pasture for your goats near the tents of the shepherds.
You,my love,excite men as a mare excites the stallions of
Pharaoh's chariots.
Your hair is beautiful upon your cheeks
and falls along your neck like jewels.
But we will make for you a chain of gold with ornaments of silver.
The Woman
My king was lying on his couch,
and my perfume filled the air with fragrance.
My lover has the scent of myrrh as he lies upon my breasts.
My lover is like the wild flowers
that bloom in the vineyards at Engedi.
The Man
How beautiful you are,my love;
how your eyes shine with love!
The Woman
How handsome you are,my dearest;
how you delight me!
The green grass will be our bed;
the cedars will be the beams of our house,
and the cypress-trees the ceiling.
I am only a wild flower in Sharon,
a lily in a mountain valley.
The Man
Like a lily among thorns
is my darling among women.
The Woman
Like an apple-tree among the trees of the forest,
so is my dearest compared with other men.
I love to sit in its shadow,
and its fruit is sweet to my taste.
He brought me to his banqueting hall
and raised the banner of love over me.
Restore my strength with raisins
and refresh me with apples!
I am weak from passion.
His left hand is under my head,
and his right hand caresses me.
Promise me,women of Jerusalem;
swear by the swift deer and the gazelles
that you will not interrupt our love.
How beautiful the song is! The God is moved by the holy love between them and decides to help them run away to that place
having full-blown the green grass,the cedars,the cypress-trees and the flowers .There are many cities at that time,such as
Jerusalem,Bethlehem,Carmel,Hebron,Ziklog,Beersheba,Gath,Libnah,Ekron,Beth Horon,Shiloh,Gilgal,and so on.The two lovers
sets out from Jerusalem,and the destination is The Garden of Eden.There are roads between cities,each road has a
guard who has "pguard" power to beat and "sguard" speed to run.The two lovers can run away together,they have "plovers"
power to beat and "slovers" speed to run. They can go through the road if and only if their power "plovers" is bigger than the guard and the speed "slovers"
is bigger than the guard..The God help them calculate the cost of each road,and place a
heart-shaped elixir,associated with a letter to distinguish them,in each road.Your task is to minimize the cost
and display the letters of elixirs they will get in the way.
输入格式
There will be several test cases.The first line contains two integers n(1<=n<=100) indicates the number of cities,and m(1<=m<=4000)
indicates the number of roads between cities.The next m lines list the power and speed of the guard,the cost and the letter of the elixir
the God placed for each road.Each line has the form:
u v pguard sguard cost letter while u and v represents the edge ,pguard and sguard represents power and speed of the guard, cost represents the cost of
the road and letter represents the letter of the elixir the God placed.The last line contains
plovers slovers. The city numberd 0 represents Jerusalem,while n-1 represents The Garden of Eden.
输出格式
For each test case,you should output the letters of the elixirs they get in the way which minimize the cost.
There'll be an empty line following each test case.
样例输入
5 5 0 1 10 10 10 L 0 2 20 14 10 A 1 2 10 10 20 o 2 3 10 10 10 V 3 4 5 30 10 E 14 35
样例输出
LoVE
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
using namespace std;
typedef struct Node{
int p, s;
char l;
}node;
node e[105][105];
int n,m,dist[105],g[105][105],fa[105],plove,slove;
inline bool relax(int u,int v)
{
if(dist[u]+g[u][v]<dist[v])
{
dist[v]=dist[u]+g[u][v];
return true;
}
return false;
}
inline bool judge(node e){
return ((plove>e.p)&&(slove>e.s));
}
void spfa(int s)
{
int vis[n+5];
memset(vis,0,sizeof(vis));
queue<int> q;
q.push(s);
vis[s] = true;
dist[s] = 0;
while(!q.empty())
{
int temp=q.front();
q.pop();
for(int i=0;i<n;i++)
if(g[temp][i]&&judge(e[temp][i])&&relax(temp,i))
{
q.push(i);
fa[i]=temp;
vis[i]=true;
}
vis[temp]=false;
}
}
int main()
{
int i,j,a,b,p,s,c;
char l;
while(scanf("%d %d",&n,&m)==2){
memset(g,0,sizeof(g));
memset(e,0,sizeof(e));
memset(fa,-1,sizeof(fa));
for(i=0;i<n;i++)
dist[i]=0x7fffffff;
for(i=0;i<m;i++){
scanf("%d%d%d%d%d %c",&a,&b,&p,&s,&c,&l);
g[a][b]=g[b][a]=c;
e[a][b].p=e[b][a].p=p;
e[a][b].s=e[b][a].s=s;
e[a][b].l=e[b][a].l=l;
}
scanf("%d %d",&plove,&slove);
spfa(0);
i=n-1,j=0;
node st[105];
while(i){
st[j++]=e[fa[i]][i];
i=fa[i];
}
for(i=j-1;i>=0;i--)
printf("%c",st[i].l);
printf("\n\n");
}
return 0;
}
#include<stdio.h>
#include<stdlib.h>
#define INF 53356
char str[101][101];
int tmp =0;
void Ppath(int path[][100],int i2,int j2);
void Dispath(int A[][100],int path[][100],int n);
int main()
{
int ncity,nrode;
while(scanf("%d%d",&ncity,&nrode)!=EOF)
{
int a[4000][5];
char b[4000];
char c[4000];
int i,j;
for(i=0;i<nrode;i++)
{
for(j=0;j<5;j++)
{
scanf("%d",&a[i][j]);
}
scanf("%s",&b[i]);
}
int pl,sl;
scanf("%d%d",&pl,&sl);
int n,i1,j1,k1;
int G[100][100];
int A[100][100],path[100][100];
for(i1=0;i1<ncity;i1++)
for(j1=0;j1<ncity;j1++)
{
A[i1][j1]=INF;
G[i1][j1]=INF;
}
for(n=0;n<nrode;n++)
{
int p,q;
p=a[n][0];
q=a[n][1];
G[p][q]=a[n][4];
str[p][q]=b[n];
}
for(i1=0;i1<ncity;i1++)
for(j1=0;j1<ncity;j1++)
{
A[i1][j1]=G[i1][j1];
path[i1][j1]=-1;
}
for(n=0;n<nrode;n++)
{
int p,q;
p=a[n][0];
q=a[n][1];
if(a[n][2]>pl||a[n][3]>sl)
{
A[p][q]=INF;
}
}
for(k1=0;k1<ncity;k1++)
{
for(i1=0;i1<ncity;i1++)
for(j1=0;j1<ncity;j1++)
if(A[i1][j1]>A[i1][k1]+A[k1][j1])
{
A[i1][j1]=A[i1][k1]+A[k1][j1];
path[i1][j1]=k1;
}
}
Dispath(A,path,ncity);
}
return 0;
}
void Ppath(int path[][100],int i2,int j2)
{
int k2;
k2=path[i2][j2];
if(k2==-1)
{
return;
}
Ppath(path,i2,k2);
printf("%c",str[tmp][k2]);
tmp = k2;
Ppath(path,k2,j2);
}
void Dispath(int A[][100],int path[][100],int n)
{
Ppath(path,0,n-1);
printf("%c",str[tmp][n-1]);
}