For this Question: There are n cities in the universe and our beloved Spider-Man is in city 1. He doesn't like to travel by vehicles, so he shot webs forming edges between some pairs of cities. Eventually, there were m edges and each had some cost associated with it.

Spider-Man now defines the cost of a path p from cities p<sub>1</sub> to p<sub>k</sub> as w<sub>1</sub> + 2w<sub>2</sub> + 3w<sub>3</sub> . . . + (k-1)*w<sub>k-1</sub>, where w<sub>i</sub> is the cost of an edge from p<sub>i</sub> to p<sub>i+1</sub>. 
Thus, the minimum distance between cities i and j is the smallest cost of a path starting from i and ending at j.

Find the minimum distance from city 1 to all the cities i (1 ≤ i ≤ n). If there exists no way to go from city 1 to city i, print -1.

<b>Note: </b>
All the edges are bidirectional. There may be multiple edges and self-loops in the input.The first line contains two space separated integers n and m - the number of nodes and edges respectively.
The next m lines contain three-space separated integers x, y, w - representing an edge between x and y with cost w.

<b>Constraints:</b>
1 ≤ n ≤ 3000
0 ≤ m ≤ 10000
1 ≤ x, y ≤ n
1 ≤ w ≤ 10<sup>9</sup>Output n lines. In the i<sup>th</sup> line, output the minimum distance from city 1 to the i<sup>th</sup> city. If there exists no such path, output -1.Sample Input
6 5
2 4 3
2 3 4
2 1 2
2 5 6
1 5 2

Sample Output
0
2
10
8
2
-1

Explanation:
Shortest path from 1 to 3 is (1->2->3)  with total weight= 1*2+2*4=10
Shortest path from 1 to 5 is (1->5)  with total weight= 1*2=2
There doesn't exist any path from 1 to 6 so print -1
, I have written this Solution Code: #include<bits/stdc++.h>

using namespace std;

#define int long long


const int INF =1e18;

vector<tuple<int, int, int>> adj;
void solve()
{
	int n, m;
	cin>>n>>m;
	// assert(1<=n && n<=3000);
	// assert(0<=m && m<=10000);

	adj.resize(n);

	for(int i = 0;i<m;i++)
	{
		int x, y, w;
		cin>>x>>y>>w;

		x--;
		y--;	
		// assert(0<=x && x<n);
		// assert(0<=y && y<n);
		// assert(1<=w && w<=1e9);
		adj.push_back({x, y, w});
		adj.push_back({y, x, w});

	}


	vector<int> dp_old(n, INF);
	vector<int> dp_new(n, INF);
	dp_old[0] = 0;


	for(int i = 1;i<=n;i++)
	{
		fill(dp_new.begin(), dp_new.end(), INF);
		for(auto [x, y,w]:adj)
		{
			dp_new[y]= min({dp_new[y], dp_old[x] + i * w});
		}

		for(int j = 0;j<n;j++)
			dp_new[j] = min(dp_new[j], dp_old[j]);
		
		swap(dp_new, dp_old);
	}

	for(int i = 0;i<n;i++)
	{
		if(dp_old[i] == INF)
			dp_old[i] = -1;
		cout<<dp_old[i]<<"\n";
	}
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cerr.tie(NULL);

	#ifndef ONLINE_JUDGE
	    if (fopen("INPUT.txt", "r"))
	    {
	        freopen("INPUT.txt", "r", stdin);
	        freopen("OUTPUT.txt", "w", stdout);

	    }
	#endif

	solve();



}, In this Programming Language: C++, Now tell me if this Code is compilable or not?