結果
問題 | No.335 門松宝くじ |
ユーザー | kei |
提出日時 | 2018-10-19 23:50:24 |
言語 | Rust (1.77.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 4,598 bytes |
コンパイル時間 | 12,044 ms |
コンパイル使用メモリ | 388,072 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-18 22:59:11 |
合計ジャッジ時間 | 42,784 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
コンパイルメッセージ
warning: use of deprecated function `std::thread::sleep_ms`: replaced by `std::thread::sleep` --> src/main.rs:85:18 | 85 | std::thread::sleep_ms(1990); | ^^^^^^^^ | = note: `#[warn(deprecated)]` on by default warning: comparison is useless due to type limits --> src/main.rs:90:16 | 90 | if Ans[i] >= 0{continue;} | ^^^^^^^^^^^ | = note: `#[warn(unused_comparisons)]` on by default
ソースコード
#![allow(unused_mut, non_snake_case,unused_imports)] use std::iter; use std::cmp::{max, min, Ordering}; use std::mem::{swap}; use std::collections::{HashMap,BTreeMap,HashSet,BTreeSet,BinaryHeap,VecDeque}; use std::iter::FromIterator; use std::sync::*; // 高速 EOF要 //macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();input_inner!{iter, $($r)*}};($($r:tt)*) => {let mut s = {use std::io::Read;let mut s = String::new();std::io::stdin().read_to_string(&mut s).unwrap();s};let mut iter = s.split_whitespace();input_inner!{iter, $($r)*}};} //macro_rules! input_inner {($iter:expr) => {};($iter:expr, ) => {};($iter:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($iter, $t);input_inner!{$iter $($r)*}};} //macro_rules! read_value {($iter:expr, ( $($t:tt),* )) => {( $(read_value!($iter, $t)),* )};($iter:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()};($iter:expr, chars) => {read_value!($iter, String).chars().collect::<Vec<char>>()};($iter:expr, usize1) => {read_value!($iter, usize) - 1};($iter:expr, $t:ty) => {$iter.next().unwrap().parse::<$t>().expect("Parse error")};} // 低速 EOF不要 macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};} macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};} macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};} /* <url:> 問題文============================================================ ================================================================= 解説============================================================= ================================================================ */ fn kadomatsu(a:usize,b:usize,c:usize) -> bool{ if b>a && b>c {return true;} if b<a && b<c {return true;} return false; } fn calc(N:usize,V:Vec<usize>) -> usize{ let mut ret = 0; for i in 0..N{ for j in i+1..N{ let mut T = 0; for k in 0..i{ if kadomatsu(V[k],V[i],V[j]) { T = max(T, max(V[k], max(V[i], V[j]))); } } for k in i+1..j{ if kadomatsu(V[i],V[k],V[j]) { T = max(T, max(V[k], max(V[i], V[j]))); } } for k in j+1..N{ if kadomatsu(V[i],V[j],V[k]) { T = max(T, max(V[k], max(V[i], V[j]))); } } ret += T; } } return ret; } fn main(){ input!(N:usize,M:usize,E:[[usize;N];M]); let N:usize = N; let M:usize = M; let mut E:Vec<Vec<usize>> = E; for i in 0..M{ E[i].push(i); } let Ans = Arc::new(Mutex::new(vec![0;M])); { for V in E.into_iter(){ let Ans = Ans.clone(); std::thread::spawn(move||{ let &idx = V.last().unwrap(); let ret = calc(N,V); loop { let mut Ans = Ans.lock().unwrap(); if Ans[idx] == 0{ println!("-> {}",ret); Ans[idx] = ret; break; } } }); } } std::thread::sleep_ms(1990); loop{ let mut Ans = Ans.lock().unwrap(); let mut ok = true; for i in 0..M{ if Ans[i] >= 0{continue;} else {ok = false;} } if ok{ println!("{:?}",*Ans); let &maxv = (*Ans).iter().max().unwrap(); for i in 0..M{ if maxv == Ans[i]{ println!("{}",i); break; } } break; } } }