結果
問題 | No.1210 XOR Grid |
ユーザー | fukafukatani |
提出日時 | 2020-08-31 21:56:04 |
言語 | Rust (1.77.0 + proconio) |
結果 |
RE
|
実行時間 | - |
コード長 | 6,117 bytes |
コンパイル時間 | 12,080 ms |
コンパイル使用メモリ | 378,424 KB |
実行使用メモリ | 11,040 KB |
最終ジャッジ日時 | 2024-11-17 02:33:59 |
合計ジャッジ時間 | 15,685 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | RE | - |
testcase_01 | AC | 2 ms
5,248 KB |
testcase_02 | RE | - |
testcase_03 | AC | 2 ms
5,248 KB |
testcase_04 | AC | 2 ms
5,248 KB |
testcase_05 | AC | 2 ms
5,248 KB |
testcase_06 | AC | 2 ms
5,248 KB |
testcase_07 | AC | 2 ms
5,248 KB |
testcase_08 | AC | 1 ms
5,248 KB |
testcase_09 | AC | 2 ms
5,248 KB |
testcase_10 | AC | 2 ms
5,248 KB |
testcase_11 | AC | 1 ms
5,248 KB |
testcase_12 | AC | 2 ms
5,248 KB |
testcase_13 | AC | 1 ms
5,248 KB |
testcase_14 | AC | 2 ms
5,248 KB |
testcase_15 | AC | 2 ms
5,248 KB |
testcase_16 | AC | 2 ms
5,248 KB |
testcase_17 | AC | 2 ms
5,248 KB |
testcase_18 | RE | - |
testcase_19 | AC | 1 ms
5,248 KB |
testcase_20 | AC | 1 ms
5,248 KB |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | AC | 2 ms
5,248 KB |
testcase_24 | AC | 1 ms
5,248 KB |
testcase_25 | AC | 129 ms
9,472 KB |
testcase_26 | AC | 27 ms
9,216 KB |
testcase_27 | RE | - |
testcase_28 | RE | - |
testcase_29 | AC | 24 ms
9,344 KB |
testcase_30 | AC | 19 ms
7,524 KB |
testcase_31 | RE | - |
testcase_32 | RE | - |
testcase_33 | AC | 1 ms
5,248 KB |
testcase_34 | AC | 1 ms
5,248 KB |
testcase_35 | RE | - |
testcase_36 | AC | 6 ms
5,248 KB |
testcase_37 | AC | 7 ms
5,248 KB |
testcase_38 | RE | - |
testcase_39 | RE | - |
testcase_40 | RE | - |
testcase_41 | RE | - |
testcase_42 | RE | - |
testcase_43 | RE | - |
testcase_44 | RE | - |
testcase_45 | RE | - |
testcase_46 | RE | - |
testcase_47 | RE | - |
testcase_48 | RE | - |
testcase_49 | RE | - |
testcase_50 | RE | - |
testcase_51 | RE | - |
testcase_52 | RE | - |
testcase_53 | RE | - |
testcase_54 | RE | - |
testcase_55 | RE | - |
testcase_56 | RE | - |
testcase_57 | RE | - |
testcase_58 | RE | - |
testcase_59 | RE | - |
コンパイルメッセージ
warning: unreachable statement --> src/main.rs:42:5 | 41 | unreachable!(); | -------------- any code following this expression is unreachable 42 | let ans = Modulo(2).pow(x).pow(n as i64 - 1).pow(m as i64 - 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unreachable statement | = note: `#[warn(unreachable_code)]` on by default warning: unused variable: `x` --> src/main.rs:20:16 | 20 | let (n, m, x) = (v[0] as usize, v[1] as usize, v[2]); | ^ help: if this is intentional, prefix it with an underscore: `_x` | = note: `#[warn(unused_variables)]` on by default warning: associated items `set_modulus` and `inv` are never used --> src/main.rs:63:8 | 62 | impl Modulo { | ----------- associated items in this implementation 63 | fn set_modulus(m: i64) { | ^^^^^^^^^^^ ... 93 | fn inv(self) -> Modulo { | ^^^ | = note: `#[warn(dead_code)]` on by default
ソースコード
#![allow(unused_imports)] #![allow(non_snake_case)] use std::cmp::*; use std::collections::*; use std::io::Write; #[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 v = read_vec::<i64>(); let (n, m, x) = (v[0] as usize, v[1] as usize, v[2]); let a = read_vec::<i64>(); let b = read_vec::<i64>(); if n == 1 { if b.iter().fold(0, |s, x| x ^ s) == a[0] { println!("1"); } else { println!("0"); } return; } if m == 1 { if a.iter().fold(0, |s, x| x ^ s) == b[0] { println!("1"); } else { println!("0"); } return; } unreachable!(); let ans = Modulo(2).pow(x).pow(n as i64 - 1).pow(m as i64 - 1); println!("{}", ans); } 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() } #[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] struct Modulo(i64); static mut MODULUS: i64 = 1000000007; impl Modulo { fn set_modulus(m: i64) { unsafe { MODULUS = m; } } fn get_modulus() -> i64 { unsafe { MODULUS } } fn new(x: i64) -> Modulo { let m = Modulo::get_modulus(); if x < 0 { Modulo(x % m + m) } else if x < m { Modulo(x) } else { Modulo(x % m) } } fn pow(self, p: i64) -> Modulo { if p == 0 { Modulo(1) } else { let mut t = self.pow(p / 2); t *= t; if p & 1 == 1 { t *= self; } t } } fn inv(self) -> Modulo { self.pow(Modulo::get_modulus() - 2) } } impl std::fmt::Display for Modulo { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { self.0.fmt(f) } } impl std::ops::AddAssign for Modulo { fn add_assign(&mut self, other: Modulo) { let m = Modulo::get_modulus(); self.0 += other.0; if self.0 >= m { self.0 -= m; } } } impl std::ops::MulAssign for Modulo { fn mul_assign(&mut self, other: Modulo) { let m = Modulo::get_modulus(); self.0 *= other.0; self.0 %= m; } } impl std::ops::SubAssign for Modulo { fn sub_assign(&mut self, other: Modulo) { let m = Modulo::get_modulus(); self.0 += m - other.0; if self.0 >= m { self.0 -= m; } } } macro_rules! impl_modulo_ops { ($imp:ident, $method:ident, $assign_imp:ident, $assign_method:ident) => { impl<'a> std::ops::$assign_imp<&'a Modulo> for Modulo { fn $assign_method(&mut self, other: &'a Modulo) { std::ops::$assign_imp::$assign_method(self, *other); } } impl std::ops::$imp for Modulo { type Output = Modulo; fn $method(self, other: Modulo) -> Modulo { let mut x = self; std::ops::$assign_imp::$assign_method(&mut x, other); x } } impl<'a> std::ops::$imp<Modulo> for &'a Modulo { type Output = Modulo; fn $method(self, other: Modulo) -> Modulo { std::ops::$imp::$method(*self, other) } } impl<'a> std::ops::$imp<&'a Modulo> for Modulo { type Output = Modulo; fn $method(self, other: &'a Modulo) -> Modulo { std::ops::$imp::$method(self, *other) } } impl<'a, 'b> std::ops::$imp<&'b Modulo> for &'a Modulo { type Output = Modulo; fn $method(self, other: &'b Modulo) -> Modulo { std::ops::$imp::$method(*self, *other) } } impl std::ops::$assign_imp<i64> for Modulo { fn $assign_method(&mut self, other: i64) { std::ops::$assign_imp::$assign_method(self, Modulo::new(other)); } } impl<'a> std::ops::$assign_imp<&'a i64> for Modulo { fn $assign_method(&mut self, other: &'a i64) { std::ops::$assign_imp::$assign_method(self, *other); } } impl std::ops::$imp<i64> for Modulo { type Output = Modulo; fn $method(self, other: i64) -> Modulo { let mut x = self; std::ops::$assign_imp::$assign_method(&mut x, other); x } } impl<'a> std::ops::$imp<&'a i64> for Modulo { type Output = Modulo; fn $method(self, other: &'a i64) -> Modulo { std::ops::$imp::$method(self, *other) } } impl<'a> std::ops::$imp<i64> for &'a Modulo { type Output = Modulo; fn $method(self, other: i64) -> Modulo { std::ops::$imp::$method(*self, other) } } impl<'a, 'b> std::ops::$imp<&'b i64> for &'a Modulo { type Output = Modulo; fn $method(self, other: &'b i64) -> Modulo { std::ops::$imp::$method(*self, *other) } } }; } impl_modulo_ops!(Add, add, AddAssign, add_assign); impl_modulo_ops!(Mul, mul, MulAssign, mul_assign); impl_modulo_ops!(Sub, sub, SubAssign, sub_assign); use std::iter::Sum; impl Sum for Modulo { fn sum<I>(iter: I) -> Self where I: Iterator<Item = Modulo>, { iter.fold(Modulo(0), |a, b| a + b) } } impl<'a> Sum<&'a Modulo> for Modulo { fn sum<I>(iter: I) -> Self where I: Iterator<Item = &'a Self>, { iter.fold(Modulo(0), |a, b| a + b) } }