Task: | Suuremmat |
Sender: | antti_p |
Submission time: | 2021-01-23 17:07:52 +0200 |
Language: | Rust |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 35 |
#2 | ACCEPTED | 65 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.01 s | 1, 2 | details |
#2 | ACCEPTED | 0.01 s | 2 | details |
Compiler report
warning: unused variable: `ignore` --> input/code.rs:83:13 | 83 | let mut ignore = true; | ^^^^^^ help: consider prefixing with an underscore: `_ignore` | = note: `#[warn(unused_variables)]` on by default 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 warning: variable does not need to be mutable --> input/code.rs:83:9 | 83 | let mut ignore = true; | ----^^^^^^ | | | help: remove this `mut` warning: function is never used: `jarjesta` --> input/code.rs:32:4 | 32 | fn jarjesta(a: &mut [usize]) -> bool { | ^^^^^^^^ | = note: `#[warn(dead_code)]` 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);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 {println!("{}", [first].iter().cycle().take(size).collect::<String>());return}}'\n' => {break;}_ => panic!(),}}if first != '9' {println!("{}", [((first as u8 + 1) as char)].iter().cycle().take(size).collect::<String>());} else {println!("{}", ['1'].iter().cycle().take(size + 1).collect::<String>());}}fn jarjesta(a: &mut [usize]) -> bool {for n in 0..a.len() {//println!("State of the array: {:?}", a);let mut pos = a.iter().enumerate().find(|(_, &x)| x == n).unwrap().0;if pos == n {continue} else if pos == n + 1 {if pos + 3 >= a.len() {//println!("Returning false from a");return false;}let tmp = a[pos - 1];a[pos - 1] = a[pos + 1];a[pos + 1] = tmp;let tmp = a[pos];a[pos] = a[pos + 2];a[pos + 2] = tmp;pos = pos + 2;} else if pos + 1 == a.len() {if n + 4 >= a.len() {//println!("Returning false from b");return false;}let tmp = a[pos - 1];a[pos - 1] = a[pos - 3];a[pos - 3] = tmp;let tmp = a[pos];a[pos] = a[pos - 2];a[pos - 2] = tmp;pos = pos - 2;}let tmp = a[pos];a[pos] = a[n];a[n] = tmp;let tmp = a[pos + 1];a[pos + 1] = a[n + 1];a[n + 1] = tmp;}true}fn main() {let stdin = io::stdin();let mut lines = stdin.lock().lines();let count = lines.next().unwrap().unwrap().parse::<usize>().unwrap();let mut ignore = true;for line in lines.take(count) {suurempi(&line.unwrap());/*if !ignore {let mut v : Vec<_> = line.unwrap().split_whitespace().map(|x| x.parse::<usize>().unwrap() - 1).collect();if jarjesta(&mut v) {println!("YES");} else {println!("NO");}}ignore = !ignore;*/}}
Test details
Test 1
Group: 1, 2
Verdict: ACCEPTED
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: ACCEPTED
input |
---|
1000 735425311146082632 756615631808964686 466489470801941584 100417544394053220 ... |
correct output |
---|
777777777777777777 777777777777777777 555555555555555555 111111111111111111 555555555555555555 ... |
user output |
---|
777777777777777777 777777777777777777 555555555555555555 111111111111111111 55555555555555 ... Truncated |