#include #include #include #include using namespace std; int urandom(int limit) { int val = random() / (RAND_MAX/limit); if (val >= limit) val = limit-1; return val; } void add_edges(int m, vector >& graph) { int const n = graph.size(); for(int k=0 ; k >& graph) { graph.clear(); graph.resize(n); long long n_long = n; long long m_long = m; long long n2 = n_long * n_long; if (2*m_long < n2){ add_edges(m, graph); } else { if(m>n2) m=n2; add_edges(n*n-m, graph); for(int i=0 ; i s; for(int j=0 ; j > graph; generate(n, m, graph); printf("%d %d\n", n, m); for(int i=0 ; i const& s(graph[i]); for(set::iterator it=s.begin() ; it!=s.end() ; ++it){ printf("%d %d %d\n", i, *it, urandom(100)+1); } } return 0; }