結果
| 問題 |
No.2224 UFO Game
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-02-24 21:27:32 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 6,684 bytes |
| コンパイル時間 | 12,727 ms |
| コンパイル使用メモリ | 386,596 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-13 05:03:48 |
| 合計ジャッジ時間 | 13,555 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 11 |
ソースコード
#![allow(unused_macros, unused_imports, dead_code)]
use std::any::TypeId;
use std::cmp::{max, min, Reverse};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::mem::swap;
use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Rem, Sub, SubAssign};
mod my_string {
use std::ops::{Index, IndexMut};
use std::slice::SliceIndex;
#[derive(Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
pub struct Str {
vc: Vec<char>,
}
impl Str {
pub fn new() -> Self {
Self { vc: vec![] }
}
pub fn from(s: &str) -> Self {
Self {
vc: s.to_string().chars().collect::<Vec<char>>(),
}
}
pub fn len(&self) -> usize {
self.vc.len()
}
pub fn clear(&mut self) {
self.vc.clear()
}
pub fn is_empty(&self) -> bool {
self.vc.is_empty()
}
pub fn first(&self) -> Option<&char> {
self.vc.first()
}
pub fn last(&self) -> Option<&char> {
self.vc.last()
}
pub fn push(&mut self, c: char) {
self.vc.push(c);
}
pub fn push_str(&mut self, s: &str) {
for c in s.to_string().chars().collect::<Vec<char>>().into_iter() {
self.push(c);
}
}
pub fn pop(&mut self) -> Option<char> {
self.vc.pop()
}
pub fn into_iter(self) -> std::vec::IntoIter<char> {
self.vc.into_iter()
}
pub fn iter(&self) -> std::slice::Iter<char> {
self.vc.iter()
}
pub fn iter_mut(&mut self) -> std::slice::IterMut<char> {
self.vc.iter_mut()
}
pub fn swap(&mut self, a: usize, b: usize) {
self.vc.swap(a, b);
}
pub fn reverse(&mut self) {
self.vc.reverse();
}
pub fn find(&self, p: &Str) -> Option<usize> {
let s: String = self.vc.iter().collect::<String>();
let p: String = p.vc.iter().collect::<String>();
s.find(&p)
}
pub fn rfind(&self, p: &Str) -> Option<usize> {
let s: String = self.vc.iter().collect::<String>();
let p: String = p.vc.iter().collect::<String>();
s.rfind(&p)
}
pub fn into_values(self, base: char) -> Vec<usize> {
self.vc
.into_iter()
.map(|c| (c as u8 - base as u8) as usize)
.collect::<Vec<usize>>()
}
pub fn sort(&mut self) {
self.vc.sort();
}
pub fn remove(&mut self, index: usize) -> char {
self.vc.remove(index)
}
}
impl std::str::FromStr for Str {
type Err = ();
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(Str {
vc: s.to_string().chars().collect::<Vec<char>>(),
})
}
}
impl<Idx: SliceIndex<[char]>> Index<Idx> for Str {
type Output = Idx::Output;
fn index(&self, i: Idx) -> &Self::Output {
&self.vc[i]
}
}
impl<Idx: SliceIndex<[char]>> IndexMut<Idx> for Str {
fn index_mut(&mut self, index: Idx) -> &mut Self::Output {
&mut self.vc[index]
}
}
impl std::ops::Add<Str> for Str {
type Output = Str;
fn add(self, rhs: Self) -> Self::Output {
let mut ret = self;
for c in rhs.into_iter() {
ret.vc.push(c);
}
ret
}
}
impl std::ops::AddAssign<Str> for Str {
fn add_assign(&mut self, rhs: Self) {
for c in rhs.into_iter() {
self.vc.push(c);
}
}
}
impl std::ops::Add<char> for Str {
type Output = Str;
fn add(self, rhs: char) -> Self::Output {
let mut ret = self;
ret.vc.push(rhs);
ret
}
}
impl std::ops::AddAssign<char> for Str {
fn add_assign(&mut self, rhs: char) {
self.vc.push(rhs);
}
}
impl std::fmt::Display for Str {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{}", self.vc.iter().collect::<String>())
}
}
impl std::fmt::Debug for Str {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{}", self.vc.iter().collect::<String>())
}
}
}
use my_string::Str;
mod procon_reader {
use std::fmt::Debug;
use std::io::Read;
use std::str::FromStr;
pub fn read<T: FromStr>() -> T
where
<T as FromStr>::Err: Debug,
{
let stdin = std::io::stdin();
let mut stdin_lock = stdin.lock();
let mut u8b: [u8; 1] = [0];
loop {
let mut buf: Vec<u8> = Vec::with_capacity(16);
loop {
let res = stdin_lock.read(&mut u8b);
if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {
break;
} else {
buf.push(u8b[0]);
}
}
if !buf.is_empty() {
let ret = String::from_utf8(buf).unwrap();
return ret.parse().unwrap();
}
}
}
pub fn read_vec<T: std::str::FromStr>(n: usize) -> Vec<T>
where
<T as FromStr>::Err: Debug,
{
(0..n).into_iter().map(|_| read::<T>()).collect::<Vec<T>>()
}
pub fn read_vec_sub1(n: usize) -> Vec<usize> {
(0..n)
.into_iter()
.map(|_| read::<usize>() - 1)
.collect::<Vec<usize>>()
}
pub fn read_mat<T: std::str::FromStr>(h: usize, w: usize) -> Vec<Vec<T>>
where
<T as FromStr>::Err: Debug,
{
(0..h)
.into_iter()
.map(|_| read_vec::<T>(w))
.collect::<Vec<Vec<T>>>()
}
}
use procon_reader::*;
/*************************************************************************************
*************************************************************************************/
fn main() {
let mut s = read::<Str>();
if s[0] != 'x' {
let mut ans = 0;
for val in s.into_values('0').into_iter() {
ans = ans * 10 + val;
}
exit_by(ans);
} else {
let mut ans = 0;
s.remove(0);
for val in s.into_values('0').into_iter() {
ans = ans * 10 + val;
}
exit_by((1usize << 32) - ans);
}
}
fn exit_by<T: std::fmt::Display>(msg: T) {
println!("{}", msg);
std::process::exit(0);
}