CSES - Datatähti 2024 loppu - Results
Submission details
Task:Palindromi
Sender:4321Boom4321
Submission time:2024-01-20 14:29:17 +0200
Language:C++ (C++11)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:31:1: error: too many initializers for 'char [100]'
   31 | };
      | ^

Code

#include <bits/stdc++.h>

using namespace std;

//create a sring of k length with "a" than add characters from b-z until the string is n long

int main()
{
int n;
cin >> n;
int k;
cin >> k;
std::string answer;
int x = 0;
char letters[100]{
'b', 'c', 'd', 'e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t',
'b', 'c', 'd', 'e','f','g','h','i','j','k','l','m','n','o','p','q','r','s',
'u',
'b', 'c', 'd', 'e','f','g','h','i','j','k','l','m','n','o','p','q','r','s',
'w',
'b', 'c', 'd', 'e','f','g','h','i','j','k','l','m','n','o','p','q','r','s',
'x',
'b', 'c', 'd', 'e','f','g','h','i','j','k','l','m','n','o','p','q','r','s',
'y',
'b', 'c', 'd', 'e','f','g','h','i','j','k','l','m','n','o','p','q','r','s',
'z',
'b', 'c', 'd', 'e','f','g','h','i','j','k','l','m','n','o','p','q','r','s',
'b', 'c', 'd', 'e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','w','x','y','z',
'b', 'c', 'd', 'e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','w','x','y','z',
'b', 'c', 'd', 'e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','w','x','y','z'
};
    for (int i = 0; i < k; i++) {
            answer += 'a';
        }
    for (int j = k; j < n; j++){
        answer += letters[x];
        x += 1;
    }
    cout << answer << endl;
}