結果
| 問題 |
No.2297 Best Grouping
|
| コンテスト | |
| ユーザー |
Sarievo
|
| 提出日時 | 2023-05-19 20:02:36 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 1,458 bytes |
| コンパイル時間 | 16,654 ms |
| コンパイル使用メモリ | 383,268 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-18 01:31:40 |
| 合計ジャッジ時間 | 13,774 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 20 |
コンパイルメッセージ
warning: unused import: `std::str::FromStr` --> src/main.rs:1:5 | 1 | use std::str::FromStr; | ^^^^^^^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default warning: variable does not need to be mutable --> src/main.rs:10:9 | 10 | let mut n: i64 = sc.read(); | ----^ | | | help: remove this `mut` | = note: `#[warn(unused_mut)]` on by default warning: constant `DX` is never used --> src/main.rs:3:7 | 3 | const DX: [i32; 8] = [0, 1, 0, -1, 1, 1, -1, -1]; | ^^ | = note: `#[warn(dead_code)]` on by default warning: constant `DY` is never used --> src/main.rs:4:7 | 4 | const DY: [i32; 8] = [1, 0, -1, 0, 1, -1, -1, 1]; | ^^
ソースコード
use std::str::FromStr;
const DX: [i32; 8] = [0, 1, 0, -1, 1, 1, -1, -1];
const DY: [i32; 8] = [1, 0, -1, 0, 1, -1, -1, 1];
fn main() {
let (r, w) = (std::io::stdin(), std::io::stdout());
let mut sc = IO::new(r.lock(), w.lock());
let mut n: i64 = sc.read();
let mut mt = n / 3;
while (n - mt * 3) % 2 != 0 {
mt -= 1;
}
println!("{}", (n - mt * 3) / 2);
}
pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);
impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
pub fn new(r: R, w: W) -> Self { Self(r, std::io::BufWriter::new(w)) }
pub fn write<S: ToString>(&mut self, s: S) {
use std::io::Write;
self.1.write_all(s.to_string().as_bytes()).unwrap();
}
pub fn read<T: std::str::FromStr>(&mut self) -> T {
use std::io::Read;
let buf = self.0.by_ref().bytes()
.map(|b| b.unwrap())
.skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
.take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
.collect::<Vec<_>>();
unsafe { std::str::from_utf8_unchecked(&buf) }.parse().ok().expect("Parse error.")
}
pub fn chars(&mut self) -> Vec<char> { self.read::<String>().chars().collect() }
pub fn usize0(&mut self) -> usize { self.read::<usize>() - 1 }
pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
(0..n).map(|_| self.read()).collect()
}
}
Sarievo