/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 18ms 672.0 KiB
#3 Accepted 18ms 680.0 KiB
#4 Accepted 17ms 648.0 KiB
#5 Accepted 18ms 604.0 KiB
#6 Accepted 18ms 580.0 KiB
#7 Wrong Answer 18ms 580.0 KiB
#8 Wrong Answer 3ms 576.0 KiB
#9 Wrong Answer 2ms 328.0 KiB
#10 Wrong Answer 17ms 672.0 KiB
#11 Wrong Answer 2ms 320.0 KiB
#12 Wrong Answer 5ms 576.0 KiB
#13 Wrong Answer 12ms 576.0 KiB
#14 Wrong Answer 10ms 600.0 KiB
#15 Wrong Answer 15ms 580.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-10-03 13:21:04
Judged By
Score
30
Total Time
18ms
Peak Memory
680.0 KiB