Task: | Suuremmat |
Sender: | antti_p |
Submission time: | 2021-01-23 16:23:03 +0200 |
Language: | Rust |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
#2 | WRONG ANSWER | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | WRONG ANSWER | 0.01 s | 1, 2 | details |
#2 | WRONG ANSWER | 0.01 s | 2 | details |
Compiler report
warning: variable does not need to be mutable --> input/code.rs:7:9 | 7 | let mut chars = chars.map(|(_, x)| x); | ----^^^^^ | | | help: remove this `mut` | = note: `#[warn(unused_mut)]` on by default
Code
use std::io::{self, BufRead};fn suurempi(s: &str) {let mut chars = s.chars().enumerate().skip_while(|&(_, x)| x == '0');let (size, first) = chars.next().unwrap();let size = s.len() - size;let mut chars = chars.map(|(_, x)| x);let mut exact = true;for c in chars {match c {'0'..='9' => {if c as u8 > first as u8 {println!("{}", [((first as u8 + 1) as char)].iter().cycle().take(size).collect::<String>());return;} else if (c as u8) < first as u8 {exact = false;}}'\n' => {break;}_ => panic!(),}}if exact && first != '9' {println!("{}", [((first as u8 + 1) as char)].iter().cycle().take(size).collect::<String>());} else if exact {println!("{}", ['1'].iter().cycle().take(size + 1).collect::<String>());} else {println!("{}", [first].iter().cycle().take(size).collect::<String>());}}fn main() {let stdin = io::stdin();let mut lines = stdin.lock().lines();let count = lines.next().unwrap().unwrap().parse::<usize>().unwrap();for line in lines.take(count) {suurempi(&line.unwrap());}}
Test details
Test 1
Group: 1, 2
Verdict: WRONG ANSWER
input |
---|
1000 1 2 3 4 ... |
correct output |
---|
2 3 4 5 6 ... |
user output |
---|
2 3 4 5 6 ... Truncated |
Test 2
Group: 2
Verdict: WRONG ANSWER
input |
---|
1000 735425311146082632 756615631808964686 466489470801941584 100417544394053220 ... |
correct output |
---|
777777777777777777 777777777777777777 555555555555555555 111111111111111111 555555555555555555 ... |
user output |
---|
888888888888888888 888888888888888888 555555555555555555 222222222222222222 55555555555555 ... Truncated |