Task: | Lista |
Sender: | xnor |
Submission time: | 2022-01-22 14:34:25 +0200 |
Language: | Rust |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
#2 | WRONG ANSWER | 0 |
#3 | WRONG ANSWER | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | WRONG ANSWER | 0.01 s | 1, 2, 3 | details |
#2 | WRONG ANSWER | 0.01 s | 2, 3 | details |
#3 | WRONG ANSWER | 0.26 s | 3 | details |
#4 | WRONG ANSWER | 0.01 s | 1, 2, 3 | details |
#5 | WRONG ANSWER | 0.01 s | 1, 2, 3 | details |
#6 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
#7 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
#8 | WRONG ANSWER | 0.02 s | 3 | details |
#9 | WRONG ANSWER | 0.02 s | 3 | details |
#10 | WRONG ANSWER | 0.01 s | 3 | details |
Code
use std::io::{stdin, BufRead, BufReader}; fn main() { let mut stdin = BufReader::new(stdin()); let mut cur_line = String::new(); stdin.read_line(&mut cur_line).unwrap(); let n = cur_line.trim().parse::<usize>().unwrap(); let mut res = Vec::new(); cur_line.clear(); stdin.read_line(&mut cur_line).unwrap(); let x = cur_line.trim(); res.push(to_min_int(x)); for i in 1..n { cur_line.clear(); stdin.read_line(&mut cur_line).unwrap(); let x = cur_line.trim(); if let Some(next) = min_greater(res[i-1], x) { res.push(next); } else { println!("IMPOSSIBLE"); std::process::exit(0); } } for v in res { println!("{}", v); } } fn min_greater(x: i64, digs: &str) -> Option<i64> { if to_min_int(digs) > x { return Some(to_min_int(digs)); } let k = 10i64.pow(digs.len() as u32 - 1); let d = digs.chars().next()?; if d == '?' { for v in 1..=9 { if let Some(r) = min_greater_inner(x - v * k, &digs[1..]) { return Some(v*k + r); } } } None } fn min_greater_inner(x: i64, digs: &str) -> Option<i64> { if to_min_int(digs) > x { return Some(to_min_int(digs)); } let k = 10i64.pow(digs.len() as u32 - 1); let d = digs.chars().next()?; if d == '?' { for v in 0..=9 { if let Some(r) = min_greater(x - v * k, &digs[1..]) { return Some(v*k + r); } } } None } fn to_min_int(digs: &str) -> i64 { let mut n = 0; for d in digs.chars() { match d { '?' => n *= 10, c @ '0'..='9' => n = 10 * n + (c as u32 - b'0' as u32) as i64, _ => (), } } n }
Test details
Test 1
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
100 ?? ?? ?? ?? ... |
correct output |
---|
10 11 12 13 20 ... |
user output |
---|
IMPOSSIBLE |
Test 2
Group: 2, 3
Verdict: WRONG ANSWER
input |
---|
1000 8?? ??8? ???? ???? ... |
correct output |
---|
800 1080 1081 1082 1083 ... |
user output |
---|
IMPOSSIBLE |
Test 3
Group: 3
Verdict: WRONG ANSWER
input |
---|
1000 ?????? ?????9? ??98??? ?????5? ... |
correct output |
---|
100000 1000090 1098000 1098050 4100001 ... |
user output |
---|
IMPOSSIBLE |
Test 4
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
100 ? ? ? ? ... |
correct output |
---|
1 2 3 4 5 ... |
user output |
---|
0 1 2 3 4 ... Truncated |
Test 5
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
2 ??? ?? |
correct output |
---|
IMPOSSIBLE |
user output |
---|
0 10 |
Test 6
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
3 123 ??? 124 |
correct output |
---|
IMPOSSIBLE |
user output |
---|
IMPOSSIBLE |
Test 7
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
5 1?? ??? 2?? ??? ... |
correct output |
---|
IMPOSSIBLE |
user output |
---|
IMPOSSIBLE |
Test 8
Group: 3
Verdict: WRONG ANSWER
input |
---|
1000 ????????? ????????? ????????? ????????? ... |
correct output |
---|
100000000 100000001 100000002 100000003 100000004 ... |
user output |
---|
IMPOSSIBLE |
Test 9
Group: 3
Verdict: WRONG ANSWER
input |
---|
900 ???000000 ???000000 ???000000 ???000000 ... |
correct output |
---|
100000000 101000000 102000000 103000000 104000000 ... |
user output |
---|
0 100000000 101000000 102000000 103000000 ... Truncated |
Test 10
Group: 3
Verdict: WRONG ANSWER
input |
---|
1000 ???1????? ???0????? ???1????? ???0????? ... |
correct output |
---|
100100000 101000000 101100000 102000000 102100000 ... |
user output |
---|
100000 100000000 100100000 101000000 101100000 ... Truncated |