#include using namespace std; using ll = long long; using llu = long long unsigned; vector dx = { 0, 0, -1, 1}; vector dy = {-1, 1, 0, 0}; #define TARGET 500000000000000000LL ll scoreCal(ll a0, ll a1, ll b0, ll b1) { ll newA = (a0 + a1) / 2; ll newB = (b0 + b1) / 2; ll score = max( abs(TARGET-newA), abs(TARGET-newB)); return score; } int main() { // スタート時点のタイムスタンプ取得 auto start_time = std::chrono::high_resolution_clock::now(); int N; cin >> N; vector A(N), B(N); for (int i=0; i> A[i] >> B[i]; } vector Aorg, Borg; Aorg = A; Borg = B; vector> ret; for (int i=0; i<50; ++i) { int u = 0; int v = 0; ll minScore = scoreCal(A[0], A[0], B[0], B[0]); //cout << "1 - 1 minScore = " << minScore << endl; for (int j=1; j(time(NULL))); while(true) { A.clear(); A = Aorg; B.clear(); B = Borg; vector> ret1; for (int i=0; i<50; ++i) { int u = rand()%N; int v = rand()%N; while (u == v) { v = rand()%N; } ret1.push_back(make_pair(u+1, v+1)); ll newA = (A[u] + A[v]) / 2; ll newB = (B[u] + B[v]) / 2; A[u] = A[v] = newA; B[u] = B[v] = newB; } ll tmpScore = scoreCal(A[0], A[0], B[0], B[0]); if (tmpScore < minScore) { minScore = tmpScore; ret.clear(); ret = ret1; } // 終了時点のタイムスタンプ取得 auto end_time = std::chrono::high_resolution_clock::now(); // 経過時間の計算 auto elapsed_time = std::chrono::duration_cast(end_time - start_time).count(); // 経過時間と制限時間の比較 int time_limit = 900; // 制限時間(例: 2000ミリ秒) if (elapsed_time > time_limit) { break; } } //cout << "minScore : " << minScore << endl; cout << ret.size() << endl; for (auto x : ret) { cout << x.first << " " << x.second << endl; } return 0; }