#include using namespace std; #define OVERLOAD_REP(_1, _2, _3, name, ...) name #define REP1(i, n) for (auto i = std::decay_t{}; (i) != (n); ++(i)) #define REP2(i, l, r) for (auto i = (l); (i) != (r); ++(i)) #define rep(...) OVERLOAD_REP(__VA_ARGS__, REP2, REP1)(__VA_ARGS__) #define REP(i, l, r) rep(i, l, r+1) #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() using ll = long long; using ld = long double; using P = pair; struct Edge { int to; ll w; }; using Graph = vector >; //using Graph = vector >; const ll INF = 2e18; //const int INF = 2e9; template using vc = vector; template using vv = vector >; template using vvv = vector > >; template using pq = priority_queue; template using pq_g = priority_queue, greater >; template istream& operator>>(istream& i, vc& v) { rep(j, 0, v.size()) i>>v[j]; return i; } template ostream& operator<<(ostream& o, vc& v) { rep(j, 0, v.size()) o< bool chmin(T& a, T b) { if(a > b) { a = b; return true; } return false; } template bool chmax(T& a, T b) { if(a < b) { a = b; return true; } return false; } class Timer{ chrono::system_clock::time_point start; public: Timer() : start(chrono::system_clock::now()) {} double count(){ chrono::duration Time_ = chrono::system_clock::now() - start; return Time_.count(); } bool is_under(double x){ return (this -> count()) < x; } }; // std::uniform_int_distributionを利用した一様乱数生成クラス class Random_Gen{ random_device seed_gen; mt19937 engine; uniform_int_distribution dist; public: // Constructor [l,r]で生成する値の範囲を指定 Random_Gen() : engine(seed_gen()) {} Random_Gen(int64_t l, int64_t r) : engine(seed_gen()), dist(l,r) {} // 現在の生成する値の範囲をstd::pairで返す pair get_range(){ return make_pair(dist.min(),dist.max()); } // 生成する値の範囲を[l,r]に変更する void set_range(int64_t l, int64_t r){ uniform_int_distribution::param_type Param(l,r); dist.param(Param); } // [l,r]内の一様分布の整数を返す int64_t gen(){ return dist(engine); } int64_t operator()(){ return gen(); } }; ll mokuhyo=500000000000000000ll; ll score(vc A, vc B, vc& u, vc& v) { int X = u.size(); int N = A.size(); rep(i, 0, X) { A[u[i]] = A[v[i]] = (A[u[i]]+A[v[i]])/2; B[u[i]] = B[v[i]] = (B[u[i]]+B[v[i]])/2; } return max(abs(A[0]-mokuhyo), abs(B[0]-mokuhyo)); } int main() { // 高速化 ios::sync_with_stdio(false); cin.tie(nullptr); // 小数点の出力桁数を指定 cout << fixed << setprecision(10); // メイン ll N; cin >> N; vc A(N), B(N); rep(i, 0, N) cin >> A[i] >> B[i]; int X = 50; Timer timer; Random_Gen rand1(0, 3), rand2(0, N-1), rand3(0, X-1), rand4(-2, 2); vc u(X, 0), v(X, 0); rep(i, 0, 50) u[i] = rand2(), v[i] = rand2(); ll curscore = INF; while(timer.is_under(0.97)) { int sousa = rand1(); vc nu(u), nv(v); if(sousa == 0) { int p = rand3(), add = rand4(); nu[p] = max(0ll, min(N-1, u[p] + add)); } else if(sousa == 1) { int p = rand3(), add = rand4(); nv[p] = max(0ll, min(N-1, v[p] + add)); } else if(sousa == 2) { int p1 = rand3(), p2 = rand3(); swap(nu[p1], nu[p2]); swap(nv[p1], nv[p2]); } rep(i, 0, 50) { while(nu[i] == nv[i]) nu[i] = rand2(); } if(chmin(curscore, score(A, B, nu, nv))) { u = nu, v = nv; } } cout << u.size() << endl; rep(i, 0, u.size()) { cout << u[i]+1 << " " << v[i]+1 << endl; } return 0; }