/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 6ms 620.0 KiB
#3 Accepted 6ms 568.0 KiB
#4 Accepted 3ms 816.0 KiB
#5 Accepted 3ms 612.0 KiB
#6 Accepted 3ms 536.0 KiB
#7 Accepted 3ms 612.0 KiB
#8 Accepted 2ms 536.0 KiB
#9 Accepted 2ms 532.0 KiB
#10 Accepted 3ms 616.0 KiB
#11 Accepted 2ms 676.0 KiB
#12 Accepted 2ms 384.0 KiB
#13 Accepted 3ms 532.0 KiB
#14 Accepted 3ms 600.0 KiB
#15 Accepted 3ms 596.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pe(c) for (auto &e : c) cout << e << ' '; cout << '\n'
#define ps(b) cout << (b ? "YES" : "NO") << '\n'
#define pc cout << "Case " << tc << ": "
#ifdef LOCAL
#include "def.h"
#else
#define ck(...)
#endif
const ll M = 1e9 + 7, N = 2e3 + 5;

string com(string &s, string &r) {
    int a = s.size(), b = r.size();
    if(a>b) return s;
    else if(b>a) return r;
    else{
        for(int i=0;i<a;++i){
            if(s[i]>r[i]) return s;
            else if(r[i]>s[i]) return r;
        }
        return s;
    }
}

void test(int tc) {
	ll a = 0, b = 0, n = 0, c = 0, d = 0, i = 0, j = 0, k = 0, q = 0;
	cin >> n >> k; k++;
	string ar[n];
    for(i=0;i<n;++i) {
        cin >> ar[i];
    }
    string s = ar[0];
    for(i=0;i+k<=n;++i){
        string r;
        a = k;
        for(j=i;a--;++j){
            r+=ar[j];
        }
        s=com(s, r);
    }
    // for(auto e:s) cout << e << ' '; cout << endl;
    cout << s;
 	cout << '\n';
}

signed main() {
	cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit|cin.badbit);
	int tc = 0, t = 1;
	cin >> t;
	while (tc < t) test(++tc);
	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:54:20
Judged At
2024-10-03 13:25:03
Judged By
Score
100
Total Time
6ms
Peak Memory
816.0 KiB