HDU 4889
Scary Path Finding Algorithm
Scary Path Finding Algorithm
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 268 Accepted Submission(s): 121 Special Judge
Problem Description
Fackyyj loves the challenge phase in TwosigmaCrap(TC). One day, he meet a task asking him to find shortest path from vertex 1 to vertex n, in a graph with at most n vertices and m edges. (1 ≤ n ≤ 100,0 ≤ m ≤ n(n-1))Fackyyj solved this problem at first glance, after that he opened someone’s submission, spotted the following code: long long spfa_slf() { int n,m; cin >> n >> m; vector<pair<int,int> > edges[111]; for(int i = 0;i < m;i++) { int x,y,w; cin >> x >> y >> w; edges[x].push_back(make_pair(y,w)); } deque
Input
Input contains several test cases, please process till EOF. For each test case, there will be a single line containing an integer C. It is the constant C in the above code. (C <= 23333333)
Output
For each test case, on the first line, print two integers, n and m, indicating the number of vertices and the number of edges of your graph. Next m lines, on each line print x y w, means there is a road from x to y, cost w. 1 ≤ n ≤ 100,0 ≤ m ≤ n(n-1),|w| < 231. Note that your output shouldn’t contain any negative-cost loop.
Sample Input
1
Sample Output
4 3 1 2 1 2 3 1 3 4 1
Author
Fudan University
Source
2014 Multi-University Training Contest 3
直接进行构造。
1 | /* *************** |