Task: | Järjestäminen |
Sender: | antti_p |
Submission time: | 2021-01-23 17:03:18 +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 |
#3 | WRONG ANSWER | 0.01 s | 1, 2 | details |
#4 | WRONG ANSWER | 0.01 s | 1, 2 | details |
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 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*2) {/*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: WRONG ANSWER
input |
---|
153 1 1 2 1 2 ... |
correct output |
---|
YES YES NO NO NO ... |
user output |
---|
YES YES NO NO NO ... Truncated |
Test 2
Group: 2
Verdict: WRONG ANSWER
input |
---|
1000 59 35 29 32 50 11 15 9 21 19 45 2... |
correct output |
---|
YES NO YES NO YES ... |
user output |
---|
NO NO NO NO NO ... Truncated |
Test 3
Group: 1, 2
Verdict: WRONG ANSWER
input |
---|
720 6 1 6 4 5 2 3 6 6 3 2 1 5 4 ... |
correct output |
---|
YES NO NO NO YES ... |
user output |
---|
NO NO NO NO YES ... Truncated |
Test 4
Group: 1, 2
Verdict: WRONG ANSWER
input |
---|
1000 8 7 4 2 8 6 3 5 1 8 3 8 2 7 5 4 6 1 ... |
correct output |
---|
NO NO YES NO YES ... |
user output |
---|
NO NO NO NO NO ... Truncated |