/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 20ms 640.0 KiB
#3 Accepted 21ms 636.0 KiB
#4 Accepted 21ms 692.0 KiB
#5 Accepted 21ms 640.0 KiB
#6 Accepted 20ms 632.0 KiB
#7 Wrong Answer 22ms 640.0 KiB
#8 Wrong Answer 9ms 532.0 KiB
#9 Wrong Answer 5ms 532.0 KiB
#10 Wrong Answer 43ms 636.0 KiB
#11 Wrong Answer 1ms 532.0 KiB
#12 Wrong Answer 5ms 532.0 KiB
#13 Wrong Answer 13ms 612.0 KiB
#14 Wrong Answer 10ms 532.0 KiB
#15 Wrong Answer 18ms 532.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pi (3.141592653589)
#define mod 1000000007
#define pb push_back
#define vi vector<ll>
#define mp make_pair
#define f first
#define s second
#define sz(container) (ll) container.size()
#define setp(x) cout << fixed << setprecision(x)
#define all(container) container.begin(), container.end()
#define rall(container) container.rbegin(), container.rend()
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
int main()
{
    fast;
    int t;
    cin >> t;
    while (t--)
    {
        int n, k;
        cin >> n >> k;
        vector<string> v(n);
        for (int i = 0; i < n; ++i)
        {
            cin >> v[i];
        }
        while (k-- > 0 && v.size() > 1)
        {
            string maxConcat = "";
            int maxIndex = -1;
            for (int i = 0; i < v.size() - 1; ++i)
            {
                string concat = v[i] + v[i + 1];
                if (concat > maxConcat)
                {
                    maxConcat = concat;
                    maxIndex = i;
                }
            }
            v[maxIndex] = maxConcat;
            v.erase(v.begin() + maxIndex + 1);
        }
        string result = *max_element(v.begin(), v.end());
        cout << result << "\n";
    }
}

Information

Submit By
Type
Submission
Problem
P1083 Number concatenation
Language
C++17 (G++ 13.2.0)
Submit At
2024-08-17 04:49:10
Judged At
2024-08-17 04:49:10
Judged By
Score
30
Total Time
43ms
Peak Memory
692.0 KiB