結果
| 問題 |
No.1538 引きこもりさんは引き算が得意。
|
| コンテスト | |
| ユーザー |
silversmith
|
| 提出日時 | 2021-06-08 16:42:56 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 1,014 bytes |
| コンパイル時間 | 13,453 ms |
| コンパイル使用メモリ | 396,736 KB |
| 実行使用メモリ | 818,932 KB |
| 最終ジャッジ日時 | 2024-11-26 19:36:03 |
| 合計ジャッジ時間 | 75,797 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 MLE * 1 |
| other | AC * 14 WA * 4 TLE * 17 MLE * 19 |
コンパイルメッセージ
warning: unused variable: `N`
--> src/main.rs:12:6
|
12 | let N:i32=a[0].parse().unwrap();
| ^ help: if this is intentional, prefix it with an underscore: `_N`
|
= note: `#[warn(unused_variables)]` on by default
warning: variable `N` should have a snake case name
--> src/main.rs:12:6
|
12 | let N:i32=a[0].parse().unwrap();
| ^ help: convert the identifier to snake case: `n`
|
= note: `#[warn(non_snake_case)]` on by default
warning: variable `K` should have a snake case name
--> src/main.rs:13:6
|
13 | let K:i32=a[1].parse().unwrap();
| ^ help: convert the identifier to snake case (notice the capitalization): `k`
warning: variable `A` should have a snake case name
--> src/main.rs:15:6
|
15 | let A:Vec<_>=s.trim().split(' ').collect();
| ^ help: convert the identifier to snake case: `a`
warning: variable `A` should have a snake case name
--> src/main.rs:16:6
|
16 | let A:Vec<i32>=A.iter().map(|a| a.parse().unwrap()).collect();
| ^ help: convert the identifier to snake case: `a`
ソースコード
use std::collections::HashSet;
fn getline() -> String{
let mut __ret=String::new();
std::io::stdin().read_line(&mut __ret).ok();
return __ret;
}
fn main() {
let s=getline();
let a:Vec<_>=s.trim().split(' ').collect();
let N:i32=a[0].parse().unwrap();
let K:i32=a[1].parse().unwrap();
let s=getline();
let A:Vec<_>=s.trim().split(' ').collect();
let A:Vec<i32>=A.iter().map(|a| a.parse().unwrap()).collect();
let mut expression = Vec::new();
for i in 0..1 << A.len() {
let mut select = Vec::new();
for j in 0..A.len() {
if (1 << j) & i == 0 {
select.push(A[j]);
}
}
if select.len() == 0{
continue;
}
for sig in 0..1 << (select.len()-1) {
let mut k = select[0];
for l in 0..(select.len()-1) {
if (1 << l) & sig == 0 {
k = k - select[l + 1];
}else{
k = -k + select[l + 1];
}
}
expression.push(k)
}
}
let expression: HashSet<i32> = expression.into_iter().collect();
if expression.contains(&K){
print!("Yes");
}else{
print!("No");
}
}
silversmith