Untitled

mail@pastecode.io avatar
unknown
plain_text
14 days ago
755 B
0
Indexable
Never
#include <iostream>
#include <fstream>
#include <vector>
#include <math.h>
typedef long long ll;
using namespace std;
ll m,n,k,q;

int dp[1000];
vector<int> go[1001];
int chua[1001][1001];
bool checked[1001];
void dfs(int u)
{
    cout<<u;
    checked[u] = 1;

    for(int v : go[u])
    {
        if(!checked[v])
            dp[v] = min(dp[v], dp[u] + chua[u][v]);
            dfs(v);
    }
}
int main()
{
    cin>>m>>n>>k>>q;
    for(int i = 0; i<n;i++)
    {
        int x,y,z;
        cin>>x>>y>>z;
        go[x].push_back(y);
        //chua[x][y] = z;
    }
    for(int i = 0; i<m; i++)
    {
        checked[i] = 0;
        dp[i] = 1e7;
    }
    dp[k] = 0;
    dfs(1);
    //cout<<dp[q];
    return 0;
}
Leave a Comment