/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 18ms 624.0 KiB
#3 Accepted 18ms 632.0 KiB
#4 Accepted 17ms 684.0 KiB
#5 Accepted 18ms 764.0 KiB
#6 Accepted 18ms 620.0 KiB
#7 Wrong Answer 18ms 764.0 KiB
#8 Wrong Answer 3ms 808.0 KiB
#9 Wrong Answer 2ms 532.0 KiB
#10 Wrong Answer 16ms 764.0 KiB
#11 Wrong Answer 2ms 532.0 KiB
#12 Wrong Answer 5ms 596.0 KiB
#13 Wrong Answer 12ms 588.0 KiB
#14 Wrong Answer 10ms 764.0 KiB
#15 Wrong Answer 15ms 636.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-10-03 13:25:45
Judged By
Score
30
Total Time
18ms
Peak Memory
808.0 KiB