CSES - Datatähti 2024 loppu - Results
Submission details
Task:Palindromi
Sender:Bean Benestrom
Submission time:2024-01-20 13:17:28 +0200
Language:C++ (C++17)
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#2ACCEPTED0.00 sdetails
#3ACCEPTED0.00 sdetails
#4ACCEPTED0.00 sdetails
#5ACCEPTED0.00 sdetails
#6ACCEPTED0.00 sdetails
#7ACCEPTED0.00 sdetails
#80.00 sdetails
#9ACCEPTED0.00 sdetails
#10ACCEPTED0.00 sdetails
#11ACCEPTED0.00 sdetails
#120.00 sdetails
#13ACCEPTED0.00 sdetails
#140.00 sdetails
#150.00 sdetails
#16ACCEPTED0.00 sdetails
#17ACCEPTED0.00 sdetails

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:12:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |     for (int i=0; i<palindrome.size()/2; i++) {
      |                   ~^~~~~~~~~~~~~~~~~~~~

Code

#include <iostream>
#include <vector>


int main() {
    int N, K;

    std::cin >> N >> K;

    std::vector<char> palindrome(K);

    for (int i=0; i<palindrome.size()/2; i++) {
        char c = (char)('a'+(i%24));
        palindrome[i] = c;
        palindrome[palindrome.size()-1-i] = c;
    }

    if (palindrome.size() % 2) palindrome[palindrome.size()/2] = (char)('a'+24);

    int left = N - palindrome.size();

    if (left > 0) {
        palindrome.push_back('z');
        left--;
    }

    int i=0;
    while (left > 0) {
        palindrome.push_back((char)('a'+(i%24)));
        left--;
        i++;
    }
    
    for (char c : palindrome)  { std::cout << c; }

    return 0;
}

// 'a'+25 = z

// (i%25) last is Y

Test details

Test 1

Verdict: ACCEPTED

input
1 1

correct output
a

user output
y

Test 2

Verdict: ACCEPTED

input
2 1

correct output
ab

user output
yz

Test 3

Verdict: ACCEPTED

input
2 2

correct output
aa

user output
aa

Test 4

Verdict: ACCEPTED

input
3 1

correct output
abc

user output
yza

Test 5

Verdict: ACCEPTED

input
3 2

correct output
aab

user output
aaz

Test 6

Verdict: ACCEPTED

input
3 3

correct output
aaa

user output
aya

Test 7

Verdict: ACCEPTED

input
4 1

correct output
abca

user output
yzab

Test 8

Verdict:

input
4 2

correct output
aabc

user output
aaza

Test 9

Verdict: ACCEPTED

input
4 3

correct output
aaab

user output
ayaz

Test 10

Verdict: ACCEPTED

input
4 4

correct output
aaaa

user output
abba

Test 11

Verdict: ACCEPTED

input
100 1

correct output
abcabcabcabcabcabcabcabcabcabc...

user output
yzabcdefghijklmnopqrstuvwxabcd...
Truncated

Test 12

Verdict:

input
100 2

correct output
aabcabcabcabcabcabcabcabcabcab...

user output
aazabcdefghijklmnopqrstuvwxabc...
Truncated

Test 13

Verdict: ACCEPTED

input
100 5

correct output
aaaaabcabcabcabcabcabcabcabcab...

user output
abybazabcdefghijklmnopqrstuvwx...
Truncated

Test 14

Verdict:

input
100 10

correct output
aaaaaaaaaabcabcabcabcabcabcabc...

user output
abcdeedcbazabcdefghijklmnopqrs...
Truncated

Test 15

Verdict:

input
100 50

correct output
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

user output
abcdefghijklmnopqrstuvwxaaxwvu...
Truncated

Test 16

Verdict: ACCEPTED

input
100 90

correct output
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

user output
abcdefghijklmnopqrstuvwxabcdef...
Truncated

Test 17

Verdict: ACCEPTED

input
100 100

correct output
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

user output
abcdefghijklmnopqrstuvwxabcdef...
Truncated