結果

問題 No.1538 引きこもりさんは引き算が得意。
ユーザー silversmithsilversmith
提出日時 2021-06-08 16:42:56
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 1,014 bytes
コンパイル時間 13,422 ms
コンパイル使用メモリ 376,620 KB
実行使用メモリ 638,976 KB
最終ジャッジ日時 2024-05-05 02:39:27
合計ジャッジ時間 18,604 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
10,624 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 WA -
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 WA -
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 3 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 WA -
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 1 ms
5,376 KB
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 1 ms
5,376 KB
testcase_26 AC 1 ms
5,376 KB
testcase_27 AC 1 ms
5,376 KB
testcase_28 AC 1 ms
5,376 KB
testcase_29 AC 1 ms
5,376 KB
testcase_30 AC 1 ms
5,376 KB
testcase_31 AC 1 ms
5,376 KB
testcase_32 WA -
testcase_33 AC 1 ms
5,376 KB
testcase_34 AC 1 ms
5,376 KB
testcase_35 AC 1 ms
5,376 KB
testcase_36 AC 1 ms
5,376 KB
testcase_37 MLE -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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`

ソースコード

diff #

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");
	}
}
0