/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 18ms 648.0 KiB
#3 Accepted 18ms 616.0 KiB
#4 Accepted 18ms 696.0 KiB
#5 Accepted 18ms 672.0 KiB
#6 Accepted 18ms 624.0 KiB
#7 Wrong Answer 18ms 660.0 KiB
#8 Wrong Answer 3ms 568.0 KiB

Code

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

#define endl '\n'
#define ll long long
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

void solve() {
    ll n, m; cin >> n >> m;
    vector<string> p(n);
    rep(i, 0, n) cin >> p[i];
    
    while (m-- && sz(p) > 1) {
        ll j = 0;
        string max1 = p[0] + p[1];
        rep(i, 0, sz(p) - 1) {
            string s = p[i] + p[i + 1];
            if (s > max1) {
                max1 = s;
                j = i;
            }
        }
        
        p[j] = max1;
        p.erase(p.begin() + j + 1);
    }
    string max_ = *max_element(all(p));
    cout << max_ << endl;
}

int main() {
    fast;
    ll t; cin >> t;
    while (t--) {
        solve();
    }
    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 17:44:46
Judged At
2024-11-11 03:11:03
Judged By
Score
30
Total Time
18ms
Peak Memory
696.0 KiB