結果
問題 | No.1306 Exactly 2 Digits |
ユーザー | akakimidori |
提出日時 | 2020-12-03 00:40:44 |
言語 | Rust (1.77.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,885 bytes |
コンパイル時間 | 15,025 ms |
コンパイル使用メモリ | 401,012 KB |
実行使用メモリ | 25,716 KB |
平均クエリ数 | 1236.78 |
最終ジャッジ日時 | 2024-07-17 07:42:44 |
合計ジャッジ時間 | 42,022 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 25 ms
24,836 KB |
testcase_01 | AC | 22 ms
24,580 KB |
testcase_02 | AC | 21 ms
24,964 KB |
testcase_03 | AC | 22 ms
24,964 KB |
testcase_04 | AC | 22 ms
24,836 KB |
testcase_05 | AC | 21 ms
24,836 KB |
testcase_06 | AC | 21 ms
24,836 KB |
testcase_07 | AC | 22 ms
25,208 KB |
testcase_08 | AC | 22 ms
24,836 KB |
testcase_09 | AC | 22 ms
24,836 KB |
testcase_10 | AC | 22 ms
24,964 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | AC | 23 ms
24,964 KB |
testcase_14 | WA | - |
testcase_15 | AC | 22 ms
24,580 KB |
testcase_16 | AC | 22 ms
25,220 KB |
testcase_17 | AC | 22 ms
24,964 KB |
testcase_18 | WA | - |
testcase_19 | AC | 21 ms
24,836 KB |
testcase_20 | WA | - |
testcase_21 | AC | 21 ms
24,580 KB |
testcase_22 | AC | 21 ms
24,820 KB |
testcase_23 | AC | 22 ms
24,964 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | AC | 22 ms
24,580 KB |
testcase_29 | AC | 22 ms
24,964 KB |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | AC | 24 ms
25,220 KB |
testcase_34 | WA | - |
testcase_35 | AC | 22 ms
25,220 KB |
testcase_36 | AC | 22 ms
25,208 KB |
testcase_37 | AC | 22 ms
24,580 KB |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | AC | 23 ms
25,220 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 | 29 ms
25,220 KB |
testcase_51 | WA | - |
testcase_52 | WA | - |
testcase_53 | WA | - |
testcase_54 | AC | 34 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 | 116 ms
24,808 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 | 152 ms
25,220 KB |
testcase_98 | AC | 125 ms
24,836 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 | 266 ms
24,580 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 | 266 ms
24,580 KB |
testcase_120 | WA | - |
testcase_121 | WA | - |
testcase_122 | WA | - |
ソースコード
// (a, b), (c, d) (1 <= a, c < N, 0 <= b, d < N) // 1.5 * N * (N - 1) // // クエリのi, j は入れ替えても同じ返答 // i = 1, j = 2..(N^2 - N) で質問すると何がわかる? // iがわかるか? // // N=2 // 2 3 -> -1 0 // 3 2 -> 0 1 // // N=3 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]; let m = n as i32; 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 { ans[0] = i; break; } } 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(); 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]; } } } print!("!"); for a in ans { print!(" {}", a); } println!(); } fn main() { run(); }