MICEMAZE – Mice and Maze

 

Problem Link

#Solution

#include <bits/stdc++.h>
#include<cstring>

using namespace std;
int a[105][105];
int main() {
int n,m,ex,t;
int co=0;
cin>>n>>ex>>t>>m;

memset(a,32,sizeof a);
a[ex][ex]=0;
for(int i=0;i<m;i++)
{

int u,v,c;
cin>>u>>v>>c;
a[u][v]=c;

}

for(int k=1;k<=n;k++)
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
a[i][j]=min(a[i][j],a[i][k]+a[k][j]);

for(int i=1;i<=n;i++)
{

if(a[i][ex]<=t)
co++;
}

cout<<co<<endl;

return 0;
}

Advertisements

About waprogramming

I am in CSE,from CUET
This entry was posted in spoj, Uncategorized and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s