Task: | Palindromi |
Sender: | EmuBird |
Submission time: | 2024-01-20 15:01:00 +0200 |
Language: | Rust |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.00 s | details |
#2 | WRONG ANSWER | 0.00 s | details |
#3 | ACCEPTED | 0.00 s | details |
#4 | WRONG ANSWER | 0.00 s | details |
#5 | WRONG ANSWER | 0.00 s | details |
#6 | ACCEPTED | 0.00 s | details |
#7 | WRONG ANSWER | 0.00 s | details |
#8 | WRONG ANSWER | 0.00 s | details |
#9 | WRONG ANSWER | 0.00 s | details |
#10 | ACCEPTED | 0.00 s | details |
#11 | WRONG ANSWER | 0.00 s | details |
#12 | WRONG ANSWER | 0.00 s | details |
#13 | WRONG ANSWER | 0.00 s | details |
#14 | WRONG ANSWER | 0.00 s | details |
#15 | WRONG ANSWER | 0.00 s | details |
#16 | WRONG ANSWER | 0.00 s | details |
#17 | ACCEPTED | 0.00 s | details |
Code
use std::{io::stdin}; fn main() { let stdin = stdin(); let (n, k): (usize, usize) = { let mut s = String::new(); stdin.read_line(&mut s).unwrap(); let mut l = s.trim_end().split_whitespace(); (l.next().unwrap().parse().unwrap(), l.next().unwrap().parse().unwrap()) }; let letters: Vec<char> = "abcdefghijklmnopqrstuvwxyz".chars().collect(); let mut palindromi = String::with_capacity(n); for i in 0..(k/2) { palindromi.insert(i, letters[i % letters.len()]); palindromi.insert(palindromi.len() - 1 - i, letters[i % letters.len()]); } if k % 2 != 0 { palindromi.insert(k / 2, letters[(k / 2 + 1) % letters.len()]); } let mut offset: usize = 0; if palindromi.len() > 0 { let first_palindromi_char = palindromi.chars().next().unwrap(); let first_palindromi_char_index: usize = { // Debugger crashes for some reason with letters.iter().position(|c| c == first_palindromi_char).unwrap(); let mut index = 0; for (i, c) in letters.iter().enumerate() { if *c == first_palindromi_char { index = i; break; } } index }; if (n - k - 1) % letters.len() == first_palindromi_char_index { offset = 1; } } let mut fill = String::with_capacity(n - k); for i in 0..(n - k) { fill.push(letters[(i + offset) % letters.len()]); } assert_ne!(fill.chars().last(), palindromi.chars().next()); assert_eq!(fill.len() + palindromi.len(), n); println!("{}", fill); println!("{}", palindromi); println!("{}", fill + &*palindromi) }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
1 1 |
correct output |
---|
a |
user output |
---|
b b |
Test 2
Verdict: WRONG ANSWER
input |
---|
2 1 |
correct output |
---|
ab |
user output |
---|
a b ab |
Test 3
Verdict: ACCEPTED
input |
---|
2 2 |
correct output |
---|
aa |
user output |
---|
aa aa |
Test 4
Verdict: WRONG ANSWER
input |
---|
3 1 |
correct output |
---|
abc |
user output |
---|
bc b bcb |
Test 5
Verdict: WRONG ANSWER
input |
---|
3 2 |
correct output |
---|
aab |
user output |
---|
b aa baa |
Test 6
Verdict: ACCEPTED
input |
---|
3 3 |
correct output |
---|
aaa |
user output |
---|
aca aca |
Test 7
Verdict: WRONG ANSWER
input |
---|
4 1 |
correct output |
---|
abca |
user output |
---|
abc b abcb |
Test 8
Verdict: WRONG ANSWER
input |
---|
4 2 |
correct output |
---|
aabc |
user output |
---|
ab aa abaa |
Test 9
Verdict: WRONG ANSWER
input |
---|
4 3 |
correct output |
---|
aaab |
user output |
---|
b aca baca |
Test 10
Verdict: ACCEPTED
input |
---|
4 4 |
correct output |
---|
aaaa |
user output |
---|
abba abba |
Test 11
Verdict: WRONG ANSWER
input |
---|
100 1 |
correct output |
---|
abcabcabcabcabcabcabcabcabcabc... |
user output |
---|
abcdefghijklmnopqrstuvwxyzabcd... Truncated |
Test 12
Verdict: WRONG ANSWER
input |
---|
100 2 |
correct output |
---|
aabcabcabcabcabcabcabcabcabcab... |
user output |
---|
abcdefghijklmnopqrstuvwxyzabcd... Truncated |
Test 13
Verdict: WRONG ANSWER
input |
---|
100 5 |
correct output |
---|
aaaaabcabcabcabcabcabcabcabcab... |
user output |
---|
abcdefghijklmnopqrstuvwxyzabcd... Truncated |
Test 14
Verdict: WRONG ANSWER
input |
---|
100 10 |
correct output |
---|
aaaaaaaaaabcabcabcabcabcabcabc... |
user output |
---|
abcdefghijklmnopqrstuvwxyzabcd... Truncated |
Test 15
Verdict: WRONG ANSWER
input |
---|
100 50 |
correct output |
---|
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa... |
user output |
---|
abcdefghijklmnopqrstuvwxyzabcd... Truncated |
Test 16
Verdict: WRONG ANSWER
input |
---|
100 90 |
correct output |
---|
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa... |
user output |
---|
abcdefghij abcdefghijklmnopqrstuvwxyzabcd... Truncated |
Test 17
Verdict: ACCEPTED
input |
---|
100 100 |
correct output |
---|
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa... |
user output |
---|
abcdefghijklmnopqrstuvwxyzabcd... Truncated |