結果
| 問題 |
No.1225 I hate I hate Matrix Construction
|
| コンテスト | |
| ユーザー |
fukafukatani
|
| 提出日時 | 2020-09-11 21:59:52 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 1,594 bytes |
| コンパイル時間 | 21,921 ms |
| コンパイル使用メモリ | 379,160 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-27 12:30:47 |
| 合計ジャッジ時間 | 15,293 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 35 |
ソースコード
#![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::<usize>();
let mut s = read_vec::<i64>();
let mut t = read_vec::<i64>();
if !s.iter().any(|&x| x == 2) && !t.iter().any(|&x| x == 2) {
let ans = max(
s.iter().filter(|&&x| x == 1).count(),
t.iter().filter(|&&x| x == 1).count(),
);
println!("{}", ans);
return;
}
if s.iter().any(|&x| x == 2) && t.iter().any(|&x| x == 2) {
let mut ans = n * s.iter().filter(|&&x| x == 2).count();
ans += (n - s.iter().filter(|&&x| x == 2).count()) * t.iter().filter(|&&x| x == 2).count();
println!("{}", ans);
return;
}
if t.iter().any(|&x| x == 2) {
std::mem::swap(&mut s, &mut t);
}
let mut ans = 0;
for i in 0..n {
if s[i] == 2 {
ans += n;
} else if s[i] == 1 {
ans += 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()
}
fukafukatani