Submission #67961312


Source Code Expand

#include <algorithm>
#include <iostream>
#include <string.h>
#define malloc(x) (x*) malloc(sizeof(x))

using namespace std;
/*
string answer = "";
struct node
{
    bool exist;
    node *next[27];
};

node *createNode()
{
    node *newNode = malloc(node);
    newNode->exist = false;
    for(int i = 0 ; i <= 26 ; i++)
        newNode->next[i] = NULL;
    return newNode;
}

node *root = createNode();

void insert(string &str)
{
    node *curr = root;
    for(int i = 0 ; i < str.length() ; i++)
    {
        if(curr->next[str[i] - 'a'] == NULL)
            curr = curr->next[str[i] - 'a'];
    }
    curr->exist = true;
}

void find_answer(string &str)
{
    node *curr = root;
    for(int i = 0 ; i < str.length() ; i++)
    {
        curr = curr->next[str[i] - 'a'];
    }
    char mincode = str[0];

    for(int i = 0 ; i < 26 ; i++)
    {
        if(curr->next[i + 'a'] != NULL && i + 'a' < mincode)
    }
}
*/

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k,x;
    cin >> n >> k;
    string arr[n + 100], shortest = "{", idx = "";
    for(int i = 0; i < n ; i++)
    {
        cin >> arr[i];
    }
    sort(arr, arr + n);
    for(int i = 0 ; i < n ; i++)
    {
        string temp = "";
        for(int s = 1 ; s <= min(11, k - 1) ; s++)
        {
            temp += arr[i];
        }
        if(k <= 11)
            temp += arr[0];
        if(temp < shortest)
        {
            shortest = temp;
            idx = arr[i];
        }
    }
    for(int i = 1 ; i < k ; i++)
        cout << idx;
    cout << arr[0] << endl;
    return 0;
}

Submission Info

Submission Time
Task G - Concat (1st)
User MichaelH
Language C++ 17 (gcc 12.2)
Score 0
Code Size 1684 Byte
Status WA
Exec Time 44 ms
Memory 6776 KiB

Compile Error

Main.cpp: In function ‘int main()’:
Main.cpp:58:13: warning: unused variable ‘x’ [-Wunused-variable]
   58 |     int n,k,x;
      |             ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 625
Status
AC × 3
AC × 28
WA × 15
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, hand_90.txt, hand_91.txt, hand_92.txt, hand_98.txt, hand_99.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
hand_01.txt WA 2 ms 3512 KiB
hand_02.txt WA 3 ms 3524 KiB
hand_03.txt WA 3 ms 3532 KiB
hand_04.txt WA 3 ms 3528 KiB
hand_05.txt WA 1 ms 3592 KiB
hand_06.txt WA 1 ms 3532 KiB
hand_07.txt AC 1 ms 3432 KiB
hand_08.txt AC 1 ms 3372 KiB
hand_90.txt AC 41 ms 6776 KiB
hand_91.txt AC 41 ms 6576 KiB
hand_92.txt AC 42 ms 6472 KiB
hand_98.txt AC 41 ms 6644 KiB
hand_99.txt AC 42 ms 6512 KiB
random_01.txt AC 44 ms 6580 KiB
random_02.txt AC 33 ms 5736 KiB
random_03.txt AC 43 ms 6572 KiB
random_04.txt AC 7 ms 4028 KiB
random_05.txt AC 44 ms 6576 KiB
random_06.txt AC 44 ms 6596 KiB
random_07.txt AC 44 ms 6652 KiB
random_08.txt WA 19 ms 4928 KiB
random_09.txt WA 3 ms 3388 KiB
random_10.txt WA 3 ms 3592 KiB
random_11.txt WA 1 ms 3452 KiB
random_12.txt WA 2 ms 3528 KiB
random_13.txt WA 3 ms 3520 KiB
random_14.txt WA 3 ms 3464 KiB
random_15.txt WA 2 ms 3524 KiB
random_16.txt WA 1 ms 3468 KiB
random_17.txt AC 3 ms 3508 KiB
random_18.txt AC 1 ms 3520 KiB
random_19.txt AC 2 ms 3448 KiB
random_20.txt AC 1 ms 3412 KiB
random_21.txt AC 2 ms 3448 KiB
random_22.txt AC 1 ms 3440 KiB
random_23.txt AC 3 ms 3620 KiB
random_24.txt AC 2 ms 3528 KiB
random_25.txt AC 2 ms 3524 KiB
random_26.txt AC 2 ms 3528 KiB
random_27.txt AC 2 ms 3492 KiB
sample_01.txt AC 1 ms 3496 KiB
sample_02.txt AC 1 ms 3444 KiB
sample_03.txt AC 1 ms 3576 KiB