結果
問題 | No.1312 Snake Eyes |
ユーザー | fukafukatani |
提出日時 | 2020-12-13 10:46:07 |
言語 | Rust (1.77.0 + proconio) |
結果 |
TLE
|
実行時間 | - |
コード長 | 2,755 bytes |
コンパイル時間 | 11,313 ms |
コンパイル使用メモリ | 391,880 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-19 23:26:34 |
合計ジャッジ時間 | 57,723 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
6,812 KB |
testcase_01 | AC | 4 ms
6,944 KB |
testcase_02 | AC | 4 ms
6,944 KB |
testcase_03 | AC | 4 ms
6,944 KB |
testcase_04 | AC | 4 ms
6,940 KB |
testcase_05 | AC | 4 ms
6,944 KB |
testcase_06 | AC | 4 ms
6,944 KB |
testcase_07 | AC | 3 ms
6,940 KB |
testcase_08 | AC | 4 ms
6,944 KB |
testcase_09 | AC | 4 ms
6,940 KB |
testcase_10 | AC | 4 ms
6,940 KB |
testcase_11 | AC | 4 ms
6,940 KB |
testcase_12 | AC | 4 ms
6,940 KB |
testcase_13 | AC | 3 ms
6,940 KB |
testcase_14 | AC | 4 ms
6,940 KB |
testcase_15 | AC | 4 ms
6,944 KB |
testcase_16 | AC | 4 ms
6,940 KB |
testcase_17 | AC | 4 ms
6,940 KB |
testcase_18 | AC | 4 ms
6,944 KB |
testcase_19 | AC | 4 ms
6,940 KB |
testcase_20 | AC | 4 ms
6,940 KB |
testcase_21 | AC | 4 ms
6,940 KB |
testcase_22 | AC | 4 ms
6,940 KB |
testcase_23 | AC | 4 ms
6,940 KB |
testcase_24 | AC | 5 ms
6,944 KB |
testcase_25 | AC | 5 ms
6,944 KB |
testcase_26 | AC | 4 ms
6,940 KB |
testcase_27 | AC | 4 ms
6,944 KB |
testcase_28 | AC | 4 ms
6,940 KB |
testcase_29 | AC | 4 ms
6,940 KB |
testcase_30 | AC | 5 ms
6,944 KB |
testcase_31 | AC | 4 ms
6,944 KB |
testcase_32 | AC | 5 ms
6,944 KB |
testcase_33 | AC | 4 ms
6,940 KB |
testcase_34 | AC | 5 ms
6,940 KB |
testcase_35 | AC | 5 ms
6,940 KB |
testcase_36 | AC | 5 ms
6,944 KB |
testcase_37 | AC | 5 ms
6,940 KB |
testcase_38 | AC | 16 ms
6,940 KB |
testcase_39 | AC | 42 ms
6,940 KB |
testcase_40 | AC | 44 ms
6,940 KB |
testcase_41 | AC | 34 ms
6,944 KB |
testcase_42 | AC | 12 ms
6,940 KB |
testcase_43 | AC | 38 ms
6,944 KB |
testcase_44 | AC | 14 ms
6,944 KB |
testcase_45 | AC | 27 ms
6,944 KB |
testcase_46 | AC | 34 ms
6,940 KB |
testcase_47 | AC | 22 ms
6,940 KB |
testcase_48 | AC | 1,784 ms
6,940 KB |
testcase_49 | AC | 1,640 ms
6,940 KB |
testcase_50 | AC | 1,220 ms
6,940 KB |
testcase_51 | AC | 579 ms
6,944 KB |
testcase_52 | AC | 1,985 ms
6,940 KB |
testcase_53 | AC | 1,435 ms
6,940 KB |
testcase_54 | AC | 1,742 ms
6,944 KB |
testcase_55 | AC | 767 ms
6,940 KB |
testcase_56 | AC | 1,084 ms
6,944 KB |
testcase_57 | AC | 1,091 ms
6,944 KB |
testcase_58 | AC | 1,474 ms
6,944 KB |
testcase_59 | AC | 512 ms
6,940 KB |
testcase_60 | AC | 1,035 ms
6,948 KB |
testcase_61 | AC | 1,963 ms
6,944 KB |
testcase_62 | AC | 719 ms
6,944 KB |
testcase_63 | AC | 11 ms
6,940 KB |
testcase_64 | AC | 48 ms
6,944 KB |
testcase_65 | AC | 183 ms
6,944 KB |
testcase_66 | AC | 5 ms
6,944 KB |
testcase_67 | AC | 4 ms
6,944 KB |
testcase_68 | AC | 62 ms
6,948 KB |
testcase_69 | AC | 4 ms
6,940 KB |
testcase_70 | AC | 1,603 ms
6,940 KB |
testcase_71 | AC | 933 ms
6,944 KB |
testcase_72 | AC | 57 ms
6,940 KB |
testcase_73 | AC | 7 ms
6,940 KB |
testcase_74 | AC | 4 ms
6,940 KB |
testcase_75 | AC | 6 ms
6,940 KB |
testcase_76 | AC | 1,978 ms
6,944 KB |
testcase_77 | TLE | - |
testcase_78 | TLE | - |
testcase_79 | AC | 1,476 ms
6,940 KB |
testcase_80 | TLE | - |
testcase_81 | TLE | - |
testcase_82 | TLE | - |
testcase_83 | TLE | - |
testcase_84 | TLE | - |
testcase_85 | AC | 1,834 ms
6,940 KB |
testcase_86 | AC | 1,712 ms
6,944 KB |
testcase_87 | AC | 919 ms
6,944 KB |
コンパイルメッセージ
warning: function `read_vec` is never used --> src/main.rs:112:4 | 112 | fn read_vec<T: std::str::FromStr>() -> Vec<T> { | ^^^^^^^^ | = note: `#[warn(dead_code)]` on by default
ソースコード
#![allow(unused_imports)] use std::cmp::*; use std::collections::*; use std::io::Write; use std::ops::Bound::*; #[allow(unused_macros)] macro_rules! debug { ($($e:expr),*) => { #[cfg(debug_assertions)] $({ let (e, mut err) = (stringify!($e), std::io::stderr()); writeln!(err, "{} = {:?}", e, $e).unwrap() })* }; } fn main() { let n = read::<i64>(); let mut ans = n + 1; // debug!(with_p(2, 2)); for di in 1i64..1000001 { for i in 2.. { if (di + 1).pow(i) > n + 1 { break; } let criterion = |mid: i64| -> bool { if mid == 1 { return true; } if mid == n + 1 { return false; } let v = with_p(n, mid); if v.len() != i as usize { return v.len() > i as usize; } for num in v { if num < di { return false; } if num > di { return true; } } false }; let (_, ng) = binary_search(1, n + 1, criterion); /* if di == 1 && i == 3 { debug!(ng); debug!(criterion(1)); debug!(criterion(2)); } */ let criterion2 = |mid: i64| -> bool { let v = with_p(n, mid); if v.len() != i as usize { return false; } return v.iter().all(|&e| e == di); }; if criterion2(ng) && ng < ans { ans = ng; } } } println!("{}", ans); } type Input = i64; fn binary_search<F>(lb: Input, ub: Input, criterion: F) -> (Input, Input) where F: Fn(Input) -> bool, { assert_eq!(criterion(lb), true); assert_eq!(criterion(ub), false); let mut ok = lb; let mut ng = ub; while ng - ok > 1 { let mid = (ng + ok) / 2; if criterion(mid) { ok = mid; } else { ng = mid; } } (ok, ng) } fn with_p(mut n: i64, p: i64) -> Vec<i64> { let mut v = vec![]; while n > 0 { v.push(n % p); n /= p; } v.reverse(); v } fn read<T: std::str::FromStr>() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } fn read_vec<T: std::str::FromStr>() -> Vec<T> { read::<String>() .split_whitespace() .map(|e| e.parse().ok().unwrap()) .collect() }