NC236065. Shortest Path Fast Algorithm
描述
输入描述
There is only one test case in each test file.The first and only line of the input contains a single integer where for the sample test case and for the only secret test case.
输出描述
Output several lines in the following format to describe the input data of a simple undirected graph that makes the variable cnt in the SPFA function no less than at some time.The first line contains two integers () and (), indicating the number of vertices and edges in the graph.Then lines follow, the -th of which contains three integers , () and (), indicating that the -th edge in the graph has a weight of and connects the -th and the -th vertices.Note that a simple graph contains no self-loops and no multiple edges.
示例1
输入:
1
输出:
4 6 1 2 1 2 3 2 3 4 3 4 1 4 1 3 5 2 4 6
C++(clang++ 11.0.1) 解法, 执行用时: 3ms, 内存消耗: 384K, 提交时间: 2022-10-04 10:59:05
#include <cstdio> #include <algorithm> using namespace std; int main(){ puts("100 165"); int inf=900000; for (int i=1;i<=99;i+=3){ printf("%d %d %d\n",i,i+1,inf); printf("%d %d %d\n",i,i+2,1); printf("%d %d %d\n",i+1,i+3,1); inf=max(1,inf/2-1); printf("%d %d %d\n",i+2,i+3,inf); printf("%d %d %d\n",i+1,i+2,1); } }