結果
| 問題 | No.1141 田グリッド |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-10-19 21:26:42 |
| 言語 | Rust (1.94.0 + proconio + num + itertools) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 3,841 bytes |
| 記録 | |
| コンパイル時間 | 251 ms |
| コンパイル使用メモリ | 153,992 KB |
| 最終ジャッジ日時 | 2026-07-15 19:21:38 |
| 合計ジャッジ時間 | 1,336 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
error: expected identifier, found reserved keyword `gen`
--> src/main.rs:93:16
|
93 | fn mex(self, gen: impl IntoIterator<Item = Self::Item>) -> Self::Item where Self::Item: Ord { let mut v = self.collect::<Vec<_>>()...
| ^^^ expected identifier, found reserved keyword
|
help: escape `gen` to use it as an identifier
|
93 | fn mex(self, r#gen: impl IntoIterator<Item = Self::Item>) -> Self::Item where Self::Item: Ord { let mut v = self.collect::<Vec<_>>(); v.sort(); v.dedup(); let mut it = v.into_iter(); gen.into_iter().find(|a| if let Some(x) = it.next() { a != &x } else { true }).unwrap() }
| ++
error: expected expression, found reserved keyword `gen`
--> src/main.rs:93:184
|
93 | ...(); v.sort(); v.dedup(); let mut it = v.into_iter(); gen.into_iter().find(|a| if let Some(x) = it.next() { a != &x } else { true ...
| ^^^ expected expression
error: could not compile `main` (bin "main") due to 2 previous errors
ソースコード
#![allow(dead_code, unused_imports, unused_macros, non_snake_case)]
fn main() {
input! {
H: usize, W: usize,
A: [[i64; W]; H],
Q: usize,
queries: [(Usize1, Usize1); Q],
}
let mut prod00 = vec![vec![1; W + 2]; H + 2];
for i in 0 .. H {
for j in 0 .. W {
prod00[i + 1][j + 1] = prod00[i + 1][j] * A[i][j] % MOD;
}
}
for j in 0 .. W {
for i in 0 .. H {
prod00[i + 1][j + 1] = prod00[i][j + 1] * prod00[i + 1][j + 1] % MOD;
}
}
let mut prod01 = vec![vec![1; W + 2]; H + 2];
for i in 0 .. H {
for j in (0 .. W).rev() {
prod01[i + 1][j + 1] = prod01[i + 1][j + 2] * A[i][j] % MOD;
}
}
for j in 0 .. W {
for i in 0 .. H {
prod01[i + 1][j + 1] = prod01[i][j + 1] * prod01[i + 1][j + 1] % MOD;
}
}
let mut prod10 = vec![vec![1; W + 2]; H + 2];
for i in 0 .. H {
for j in 0 .. W {
prod10[i + 1][j + 1] = prod10[i + 1][j] * A[i][j] % MOD;
}
}
for j in 0 .. W {
for i in (0 .. H).rev() {
prod10[i + 1][j + 1] = prod10[i + 2][j + 1] * prod10[i + 1][j + 1] % MOD;
}
}
let mut prod11 = vec![vec![1; W + 2]; H + 2];
for i in 0 .. H {
for j in (0 .. W).rev() {
prod11[i + 1][j + 1] = prod11[i + 1][j + 2] * A[i][j] % MOD;
}
}
for j in 0 .. W {
for i in (0 .. H).rev() {
prod11[i + 1][j + 1] = prod11[i + 2][j + 1] * prod11[i + 1][j + 1] % MOD;
}
}
for &(r, c) in &queries {
let mut ans = 1;
ans = ans * prod00[r][c] % MOD;
ans = ans * prod01[r][c + 2] % MOD;
ans = ans * prod10[r + 2][c] % MOD;
ans = ans * prod11[r + 2][c + 2] % MOD;
say(ans);
}
}
type Int = i64;
// const MOD: Int = 998244353;
const MOD: Int = 1_000_000_007;
const INF: Int = 1_000_000_000_000_000_000;
const YESNO: [&'static str; 2] = ["Yes", "No"];
use proconio::{input, marker::{Chars, Bytes, Usize1}};
use std::*;
use std::ops::*;
use collections::*; // (BTree|Hash)(Set|Map), BinaryHeap, VecDeque, LinkedList
use cmp::{self, Reverse}; // cmp::{min, max}
fn yes() { println!("{}", YESNO[0]); }
fn no() { println!("{}", YESNO[1]); }
fn yesno(c: bool) { println!("{}", if c { YESNO[0] } else { YESNO[1] }); }
fn say<T: std::fmt::Display>(x: T) -> T { println!("{}", x); x }
fn neighbor4<F: FnMut(usize, usize)>(i: usize, j: usize, h: usize, w: usize, mut f: F) { if i > 0 { (f)(i - 1, j); } if i < h - 1 { (f)(i + 1, j); } if j > 0 { (f)(i, j - 1); } if j < w - 1 { (f)(i, j + 1); } }
trait MyItertools : Iterator + Sized {
fn to_vec(self) -> Vec<Self::Item> { self.collect::<Vec<_>>() }
fn to_vec_rev(self) -> Vec<Self::Item> { let mut v = self.collect::<Vec<_>>(); v.reverse(); v }
fn tally(self) -> HashMap<Self::Item, usize> where Self::Item: Copy + Eq + hash::Hash { let mut counts = HashMap::new(); self.for_each(|item| *counts.entry(item).or_default() += 1 ); counts }
fn count_if<P: Fn(Self::Item) -> bool>(self, predicate: P) -> usize { self.map(predicate).filter(|&x| x ).count() }
fn implode(self, sep: &str) -> String where Self::Item: std::string::ToString { self.map(|x| x.to_string()).to_vec().join(sep) }
fn mex(self, gen: impl IntoIterator<Item = Self::Item>) -> Self::Item where Self::Item: Ord { let mut v = self.collect::<Vec<_>>(); v.sort(); v.dedup(); let mut it = v.into_iter(); gen.into_iter().find(|a| if let Some(x) = it.next() { a != &x } else { true }).unwrap() }
}
impl<T: ?Sized> MyItertools for T where T: Iterator + Sized {}
trait MyOrd : PartialOrd + Sized {
fn chmax(&mut self, mut rhs: Self) -> bool { if self < &mut rhs { *self = rhs; true } else { false } }
fn chmin(&mut self, mut rhs: Self) -> bool { if self > &mut rhs { *self = rhs; true } else { false } }
}
impl<T: Sized + PartialOrd> MyOrd for T {}