#include #include #include #include using namespace std; const long long Target = 500000000000000000LL; void Operation(vector& A, vector& B, int idx1, int idx2) { long long avg1 = (A[idx1] + A[idx2]) / 2LL; long long avg2 = (B[idx1] + B[idx2]) / 2LL; A[idx1] = avg1; B[idx1] = avg2; A[idx2] = avg1; B[idx2] = avg2; } int main() { // Step 1. 入力 vector A(50, 0); vector B(50, 0); long long N; cin >> N; for (int i = 0; i < N; i++) cin >> A[i] >> B[i]; // 準備 long long RecordScore = (1LL << 60); int StartTime = clock(); vector> Answer; // Step 2. ランダムな処理 while (clock() - StartTime < 9 * CLOCKS_PER_SEC / 10) { vector C = A; vector D = B; vector> CurrentAns; for (int i = 0; i < 50; i++) { int idx1, idx2; while (true) { idx1 = rand() % (N - 1) + 1; idx2 = rand() % (N - 1) + 1; if (idx1 != idx2) break; } Operation(C, D, idx1, idx2); CurrentAns.push_back(make_pair(idx1, idx2)); } // 誤差の計算 long long MinV = (1LL << 60); long long MinID = -1; for (int i = 1; i < N; i++) { long long v1 = (C[0] + C[i]) / 2LL; long long v2 = (D[0] + D[i]) / 2LL; long long err = min(abs(v1 - Target), abs(v2 - Target)); if (MinV > err) { MinV = err; MinID = i; } } CurrentAns.push_back(make_pair(0, MinID)); // 記録と比較 if (RecordScore > MinV) { RecordScore = MinV; Answer = CurrentAns; } } // Step 3. 出力 cout << Answer.size() << endl; for (int i = 0; i < Answer.size(); i++) { cout << Answer[i].first + 1 << " " << Answer[i].second + 1 << endl; } return 0; }