Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as C++ by yo ( 15 years ago )
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
int mapa[111][111];
int pd[111], c,s,t,e,x;
#define fr(a,b,c) for( int a = b ; a < c ; ++a )
bool read() {
if( scanf("%d%d%d%d", &c, &s, &e, &t) != 4 || !c ) return false;
memset(pd,-1,sizeof pd);
fr(i,0,c) fr(j,0,c) {
scanf("%d", &mapa;[i][j]);
}
fr(i,0,e) {
scanf("%d", &x);
pd[x-1] = 0;
}
fr(i,0,t) fr(j,0,c) {
x = -1;
fr(k,0,c) if( ~pd[k] ) {
x = max(x,pd[k]+mapa[j][k]);
}
pd[j] = x;
}
printf("%dn", pd[s-1]);
return true;
}
int main() {
while( read() );
return 0;
}
Revise this Paste
Children: 36876