This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MASK(i) (1LL << (i))
#define GETBIT(mask, i) (((mask) >> (i)) & 1)
#define ALL(v) (v).begin(), (v).end()
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll LASTBIT(ll mask){return (mask) & (-mask);}
int pop_cnt(ll mask){return __builtin_popcountll(mask);}
int ctz(ll mask){return __builtin_ctzll(mask);}
int logOf(ll mask){return 63 - __builtin_clzll(mask);}
mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
ll rngesus(ll l, ll r){return l + (ull) rng() % (r - l + 1);}
template <class T1, class T2>
bool maximize(T1 &a, T2 b){
if (a < b) {a = b; return true;}
return false;
}
template <class T1, class T2>
bool minimize(T1 &a, T2 b){
if (a > b) {a = b; return true;}
return false;
}
template <class T>
void printArr(T& container, string separator = " ", string finish = "\n", ostream &out = cout){
for(auto item: container) out << item << separator;
out << finish;
}
template <class T>
void remove_dup(vector<T> &a){
sort(ALL(a));
a.resize(unique(ALL(a)) - a.begin());
}
int main(void){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n = rngesus(1e5, 1e5), m = n - 1, k = rngesus(20, min(1LL * (n-2) * (n-1) / 2, 20));
cout << n << " " << m << " " << k << "\n";
set<pair<int, int>> S;
for(int i = 1; i<=n; ++i) for(int j = i + 1; j<=n; ++j) {
S.insert({i, j});
if (S.size() > m * 3) break;
}
vector<int> perm(n-1);
for(int i = 0; i<n-1; ++i) perm[i] = i + 1;
shuffle(ALL(perm), rng);
for(int i = 2; i<=n; ++i) {
int u = rngesus(1, i-1), v = i, w = perm[i-2];
S.erase({u, v});
cout << u << " " << v << " " << w << "\n";
}
vector<pair<int, int>> edge(ALL(S));
shuffle(ALL(edge), rng);
while(k--){
int u = edge.back().first, v = edge.back().second;
edge.pop_back();
cout << u << " " << v << "\n";
}
for(int i = 1; i<=n; ++i) cout << rngesus(1, 10) << " "; cout << "\n";
return 0;
}
Compilation message (stderr)
toll.cpp: In function 'int main()':
toll.cpp:56:22: warning: comparison of integer expressions of different signedness: 'std::set<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
56 | if (S.size() > m * 3) break;
| ~~~~~~~~~^~~~~~~
toll.cpp:77:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
77 | for(int i = 1; i<=n; ++i) cout << rngesus(1, 10) << " "; cout << "\n";
| ^~~
toll.cpp:77:62: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
77 | for(int i = 1; i<=n; ++i) cout << rngesus(1, 10) << " "; cout << "\n";
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |