// -*- coding:utf-8-unix -*- use std::cell::OnceCell; use proconio::marker::{Bytes, Usize1}; use proconio::{fastout, input}; const TARGET: u64 = 500_000_000_000_000_000; const MINV: u64 = 100_000_000_000_000_000; const TARGET_ADJ: u64 = TARGET - MINV; const OP_NUM: usize = 50; #[fastout] fn main() { let _ = get_time(); input! { n: usize, mut ab: [(u64, u64); n], } for x in &mut ab { x.0 -= MINV; x.1 -= MINV; } let mut ans = Vec::new(); for _ in 0..OP_NUM { let mut best_v = 0; let mut best_score = u64::MAX; for v in 1..n { let ab_new = card_avg(ab[0], ab[v]); let new_score = card_error_max(ab_new); if new_score < best_score { best_score = new_score; best_v = v; } } ans.push((0, best_v)); ab[0] = card_avg(ab[0], ab[best_v]); } println!("{}", ans.len()); for &(u, v) in &ans { println!("{} {}", u + 1, v + 1); } // eprintln!("# Metric end_time float {}", get_time()); // std::process::exit(0); } fn card_avg(u: (u64, u64), v: (u64, u64)) -> (u64, u64) { ((u.0 + v.0) / 2, (u.1 + v.1) / 2) } fn card_error_max(u: (u64, u64)) -> u64 { (u.0.abs_diff(TARGET_ADJ)).max(u.1.abs_diff(TARGET_ADJ)) } fn card_error_sum(u: (u64, u64)) -> u64 { (u.0.abs_diff(TARGET_ADJ)) + (u.1.abs_diff(TARGET_ADJ)) } // // MARK: Time Measurement // pub fn get_time() -> f64 { static mut STIME: f64 = -1.0; let t = std::time::SystemTime::now() .duration_since(std::time::UNIX_EPOCH) .unwrap(); let ms = t.as_secs() as f64 + t.subsec_nanos() as f64 * 1e-9; unsafe { if STIME < 0.0 { STIME = ms; } ms - STIME } } #[allow(unused)] #[cfg(debug_assertions)] const TIME_LIMIT: f64 = 10.; #[allow(unused)] #[cfg(not(debug_assertions))] const TIME_LIMIT: f64 = 2.9;