思路:
构造
实现:
1 #include <bits/stdc++.h> 2 using namespace std; 3 int main() 4 { 5 int n, m; 6 cin >> n >> m; 7 cout << "100003 100003" << endl; 8 for (int i = 0; i < n - 2; i++) 9 { 10 cout << i + 1 << " " << i + 2 << " " << 1 << endl; 11 } 12 cout << n - 1 << " " << n << " " << 100005 - n << endl; 13 int cnt = 0; 14 for (int i = 1; i <= n; i++) 15 { 16 for (int j = i + 2; j <= n; j++) 17 { 18 if (cnt >= m - n + 1) break; 19 cout << i << " " << j << " 1000000000" << endl; 20 cnt++; 21 } 22 } 23 return 0; 24 }