結果
問題 | No.1306 Exactly 2 Digits |
ユーザー | akakimidori |
提出日時 | 2020-12-03 00:52:34 |
言語 | Rust (1.77.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,798 bytes |
コンパイル時間 | 24,290 ms |
コンパイル使用メモリ | 388,832 KB |
実行使用メモリ | 25,604 KB |
平均クエリ数 | 1236.78 |
最終ジャッジ日時 | 2024-07-17 07:47:22 |
合計ジャッジ時間 | 54,440 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 40 ms
24,964 KB |
testcase_01 | AC | 22 ms
24,580 KB |
testcase_02 | AC | 23 ms
25,220 KB |
testcase_03 | AC | 23 ms
25,220 KB |
testcase_04 | AC | 23 ms
25,220 KB |
testcase_05 | AC | 22 ms
24,964 KB |
testcase_06 | AC | 22 ms
24,836 KB |
testcase_07 | AC | 22 ms
25,220 KB |
testcase_08 | AC | 22 ms
25,220 KB |
testcase_09 | AC | 23 ms
24,836 KB |
testcase_10 | AC | 23 ms
24,836 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | AC | 23 ms
25,220 KB |
testcase_14 | WA | - |
testcase_15 | AC | 23 ms
24,836 KB |
testcase_16 | AC | 23 ms
25,476 KB |
testcase_17 | AC | 22 ms
25,092 KB |
testcase_18 | WA | - |
testcase_19 | AC | 23 ms
25,460 KB |
testcase_20 | WA | - |
testcase_21 | AC | 23 ms
25,220 KB |
testcase_22 | AC | 23 ms
24,964 KB |
testcase_23 | AC | 23 ms
24,824 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | AC | 23 ms
24,836 KB |
testcase_29 | AC | 23 ms
25,220 KB |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | AC | 24 ms
24,580 KB |
testcase_34 | WA | - |
testcase_35 | AC | 24 ms
25,220 KB |
testcase_36 | AC | 23 ms
24,836 KB |
testcase_37 | AC | 24 ms
24,836 KB |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | AC | 24 ms
24,836 KB |
testcase_43 | AC | 23 ms
24,580 KB |
testcase_44 | WA | - |
testcase_45 | WA | - |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | WA | - |
testcase_49 | WA | - |
testcase_50 | AC | 30 ms
24,580 KB |
testcase_51 | WA | - |
testcase_52 | WA | - |
testcase_53 | WA | - |
testcase_54 | AC | 39 ms
24,836 KB |
testcase_55 | WA | - |
testcase_56 | WA | - |
testcase_57 | WA | - |
testcase_58 | WA | - |
testcase_59 | WA | - |
testcase_60 | WA | - |
testcase_61 | WA | - |
testcase_62 | WA | - |
testcase_63 | WA | - |
testcase_64 | WA | - |
testcase_65 | WA | - |
testcase_66 | WA | - |
testcase_67 | WA | - |
testcase_68 | WA | - |
testcase_69 | WA | - |
testcase_70 | WA | - |
testcase_71 | WA | - |
testcase_72 | WA | - |
testcase_73 | AC | 137 ms
24,836 KB |
testcase_74 | WA | - |
testcase_75 | WA | - |
testcase_76 | WA | - |
testcase_77 | WA | - |
testcase_78 | WA | - |
testcase_79 | WA | - |
testcase_80 | WA | - |
testcase_81 | WA | - |
testcase_82 | WA | - |
testcase_83 | WA | - |
testcase_84 | WA | - |
testcase_85 | WA | - |
testcase_86 | WA | - |
testcase_87 | WA | - |
testcase_88 | WA | - |
testcase_89 | WA | - |
testcase_90 | WA | - |
testcase_91 | WA | - |
testcase_92 | WA | - |
testcase_93 | WA | - |
testcase_94 | WA | - |
testcase_95 | WA | - |
testcase_96 | WA | - |
testcase_97 | AC | 323 ms
24,836 KB |
testcase_98 | AC | 293 ms
25,208 KB |
testcase_99 | WA | - |
testcase_100 | WA | - |
testcase_101 | WA | - |
testcase_102 | WA | - |
testcase_103 | WA | - |
testcase_104 | WA | - |
testcase_105 | WA | - |
testcase_106 | AC | 302 ms
25,076 KB |
testcase_107 | WA | - |
testcase_108 | WA | - |
testcase_109 | WA | - |
testcase_110 | WA | - |
testcase_111 | WA | - |
testcase_112 | WA | - |
testcase_113 | WA | - |
testcase_114 | WA | - |
testcase_115 | WA | - |
testcase_116 | WA | - |
testcase_117 | WA | - |
testcase_118 | WA | - |
testcase_119 | AC | 348 ms
24,824 KB |
testcase_120 | WA | - |
testcase_121 | WA | - |
testcase_122 | WA | - |
ソースコード
fn read() -> Vec<i32> { let mut s = String::new(); std::io::stdin().read_line(&mut s).unwrap(); s.trim().split_whitespace().map(|s| s.parse().unwrap()).collect() } fn run() { let n = read()[0] as usize; let mut cnt = 0; let mut query = |x: usize, y: usize| -> (i32, i32) { assert!(x != y); assert!(x < n * n - n); assert!(y < n * n - n); assert!(cnt < n * (n - 1) / 2 * 3); cnt += 1; println!("? {} {}", x + 1, y + 1); let a = read(); (a[0], a[1]) }; let m = n as i32; let hash = |x: i32, y: i32| -> (i32, i32) { assert!(m <= x && x < m * m); assert!(m <= y && y < m * m); let mut p = x / m - y / m; let mut q = x % m - y % m; if p > q { std::mem::swap(&mut p, &mut q); } (p, q) }; let mut memo = vec![(0, 0); n * n - n]; for i in 1..(n * n - n) { memo[i] = query(0, i); } let mut key = memo.clone(); key.remove(0); key.sort(); let mut ans = vec![0; n * n - n]; for i in m..(m * m) { let mut a = vec![]; for j in m..(m * m) { if i == j { continue; } a.push(hash(i, j)); } a.sort(); if a == key { assert!(ans[0] == 0); ans[0] = i; } } let mut map = std::collections::BTreeMap::new(); for i in 1..(n * n - n) { map.entry(memo[i]).or_insert(vec![]).push(i); } for i in 1..(n * n - n) { if ans[i] != 0 { continue; } let index = map.get(&memo[i]).unwrap(); assert!(index.len() <= 2); if index.len() == 1 { for v in m..(m * m) { if v == ans[0] { continue; } if hash(ans[0], v) == memo[i] { ans[i] = v; break; } } } else { let mut cond = vec![]; for v in m..(m * m) { if v == ans[0] { continue; } if hash(ans[0], v) == memo[i] { cond.push(v); } } if query(index[0], index[1]) == hash(cond[0], cond[1]) { ans[index[0]] = cond[0]; ans[index[1]] = cond[1]; } else { ans[index[0]] = cond[1]; ans[index[1]] = cond[0]; } } } assert!(ans.iter().all(|a| m <= *a && *a < m * m)); let mut p = ans.clone(); p.sort(); p.dedup(); assert!(p.len() == n * n - n); print!("!"); for a in ans { print!(" {}", a); } println!(); } fn main() { run(); }