#include #include #include #include #include using namespace std; struct Card { int q, p; }; typedef vector VC; typedef vector VI; const int MAXT = 20; const int MAXN = 50000; int num_cases = MAXT; //assumes card pictures are from 0 to 2n-1 (n = v.size()) void dump(VC& v) { cout << v.size() << endl; for (auto c : v) cout << c.p+1 << ' ' << c.q+1 << endl; --num_cases; } void scramble(VC& v) { int n = v.size(); VI c(2*n); for (int i = 0; i < 2*n; ++i) c[i] = i; for (int i = 2*n-1; i > 0; --i) swap(c[i], c[rand()%(i+1)]); for (int i = 0; i < n; ++i) { if (rand()&1) swap(v[i].p, v[i].q); v[i].p = c[v[i].p]; v[i].q = c[v[i].q]; } } //random_yes, generated by assigning the first picture of card i to i //and the other to a random card, then scrambling void rand_yes(int n) { VC v(n); for (int i = 0; i < n; ++i) { v[i].p = i; v[i].q = rand()%n; } scramble(v); dump(v); } //random no, generated by assigning the first picture of card i < n-1 to i%k //and the other to a random card mod (k-1), and then the last card //to two completely different pictures (so # pictures == n) void rand_no(int n) { assert(n > 1); VC v(n); for (int i = 0; i < n-1; ++i) { v[i].p = i; v[i].q = (i+1)%(n-1); } v[n-1].p = n-1; v[n-1].q = n; scramble(v); dump(v); } void full_rand(int n) { VC v(n); //Very interesting threshold. Using 2*n almost always produces //"yes" instances. This one seems close to 50/50. int mod = 39*n/20; for (int i = 0; i < n; ++i) { v[i].p = rand()%mod; v[i].q = rand()%mod; } dump(v); } int main() { cout << num_cases << endl; while (num_cases) full_rand(MAXN); return 0; }