/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 320.0 KiB
#2 Accepted 18ms 612.0 KiB
#3 Accepted 18ms 660.0 KiB
#4 Accepted 18ms 688.0 KiB
#5 Accepted 20ms 664.0 KiB
#6 Accepted 19ms 652.0 KiB
#7 Wrong Answer 19ms 656.0 KiB
#8 Wrong Answer 3ms 532.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define sp " "
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl
#define no cout << "no" << endl

void messi()
{
    ll n, k;
    cin >> n >> k;
    vector<string> v(n);
    for (string &x : v)
        cin >> x;

    string ans = "";
    while (k > 0 && n > 1)
    {
        ll index = 0;
        ans = v[0] + v[1];
        for (ll i = 1; i < n - 1; i++)
        {
            string con = v[i] + v[i + 1];
            if (con > ans)
            {
                ans = con;
                index = i;
            }
        }
        v[index] = ans;
        v.erase(v.begin() + index + 1);
        n--;
        k--;
    }
    cout << ans << endl;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    ll tc = 1;
    cin >> tc;
    while (tc--)
    {
        messi();
    }
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1083 Number concatenation
Contest
Bangladesh 2.0
Language
C++20 (G++ 13.2.0)
Submit At
2024-08-16 16:50:31
Judged At
2024-11-11 03:13:49
Judged By
Score
30
Total Time
20ms
Peak Memory
688.0 KiB