結果
| 問題 |
No.8 N言っちゃダメゲーム
|
| コンテスト | |
| ユーザー |
tsubu_taiyaki
|
| 提出日時 | 2017-02-04 10:10:59 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,819 bytes |
| コンパイル時間 | 12,415 ms |
| コンパイル使用メモリ | 387,604 KB |
| 最終ジャッジ日時 | 2024-11-14 19:57:38 |
| 合計ジャッジ時間 | 13,413 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
error[E0782]: trait objects must include the `dyn` keyword
--> src/main.rs:10:21
|
10 | tokens: &'a mut Iterator<Item = String>,
| ^^^^^^^^^^^^^^^^^^^^^^^
|
help: add `dyn` keyword before this trait
|
10 | tokens: &'a mut dyn Iterator<Item = String>,
| +++
error[E0782]: trait objects must include the `dyn` keyword
--> src/main.rs:14:23
|
14 | fn new(i: &'a mut Iterator<Item = String>) -> Self {
| ^^^^^^^^^^^^^^^^^^^^^^^
|
help: add `dyn` keyword before this trait
|
14 | fn new(i: &'a mut dyn Iterator<Item = String>) -> Self {
| +++
For more information about this error, try `rustc --explain E0782`.
error: could not compile `main` (bin "main") due to 2 previous errors
ソースコード
#![allow(unused_imports)]
use std::io::{self, BufRead};
use std::str::FromStr;
use std::collections::*;
use std::cmp::*;
#[allow(dead_code)]
struct Parser<'a> {
tokens: &'a mut Iterator<Item = String>,
}
#[allow(dead_code)]
impl<'a> Parser<'a> {
fn new(i: &'a mut Iterator<Item = String>) -> Self {
Parser {tokens: i}
}
fn take<T: FromStr>(&mut self) -> T {
match self.tokens.next().expect("empty iterator").parse() {
Ok(x) => x,
Err(_) => panic!()
}
}
fn take_some<T: FromStr>(&mut self, n: usize) -> Vec<T> {
self.tokens.take(n).map(|s| match s.parse() { Ok(x) => x, Err(_) => panic!() } ).collect()
}
}
//sieve[k] is true if k is a prime
//[0, n)
#[allow(dead_code)]
fn sieve_of_eratosthenes(n: u64) -> Vec<bool> {
let mut v = vec![true; n as usize];
v[0] = false;
v[1] = false;
for i in 2..n {
if !v[i as usize] {
continue;
}
let mut j = 2*i;
while j < n {
v[j as usize] = false;
j += i;
}
}
v
}
fn solve(n: u32, k: u32) -> bool {
let mut v = vec![true; (n+k+1) as usize];
let mut s = 0;
for i in (0..n).rev() {
if !v[(i+1) as usize] {
s += 1;
}
if !v[(i+k+1) as usize] {
s -= 1;
}
v[i as usize] = s > 0;
}
v[0]
}
fn main() {
let stdin = io::stdin();
let mut tokens = stdin.lock().lines().filter_map(|x| x.ok()).flat_map(|x| x.split_whitespace().map(|s| s.to_owned()).collect::<Vec<String>>());
let mut parser = Parser::new(&mut tokens);
let p: u32 = parser.take();
for _ in 0..p {
let n = parser.take();
let k = parser.take();
println!("{}", if solve(n, k) { "Win" } else { "Lose" });
}
}
tsubu_taiyaki