/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 5ms 616.0 KiB
#3 Accepted 5ms 576.0 KiB
#4 Accepted 4ms 580.0 KiB
#5 Accepted 3ms 608.0 KiB
#6 Accepted 4ms 808.0 KiB
#7 Accepted 4ms 580.0 KiB
#8 Accepted 2ms 576.0 KiB
#9 Accepted 1ms 532.0 KiB
#10 Accepted 3ms 536.0 KiB
#11 Accepted 1ms 532.0 KiB
#12 Accepted 3ms 532.0 KiB
#13 Accepted 3ms 596.0 KiB
#14 Accepted 3ms 576.0 KiB
#15 Accepted 3ms 576.0 KiB

Code

#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#ifdef velox
#include "debug.h"
#else
#define debug(x...)
#endif

#define srt(v) sort(v.begin(),v.end())
#define grtsrt(v) sort(v.begin(),v.end(),greater<ll>())
#define unq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define set_bits(x) __builtin_popcountll(x)
#define fst_zero(x) 63-__builtin_ctzll(x)
#define lst_zero(x) __builtin_ctzll(x)
#define gcd(x,y) __gcd(x,y)
#define lcm(x,y) ((x/gcd(x,y))*y)
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define ll long long
#define pb push_back
#define endl '\n'
#define fx(x) fixed<<setprecision(x)
template <typename T> using pbds = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const ll MOD = 1e9+7;

void error_txt(){
	#ifdef velox
	freopen("error.txt","w",stderr);
	#endif
}



void solve(){
	ll len,k; cin >> len >> k;
	vector<string> v(len);

	for(int x=0; x<len; x++) cin >> v[x];

	if(len-1==k){
		string p="";
		for(int x=0; x<len; x++) p+=v[x];
		cout << p << endl;
		return;
	}

	debug(v);
	string ans="";
	for(int x=0; x<len-k; x++){
		string get="";
		get+=v[x];
		for(int y=x+1; y<=x+k; y++){
			get+=v[y];
		}
		if(get.size()==ans.size()){
			bool f=false;
			for(int j=0; j<get.size(); j++){
				debug(ans,get);
				if(get[j]>ans[j]){
					f=true;
					break;
				}
				else if(get[j]==ans[j]) continue;
				else break;
			}
			if(f) ans=get;
		}
		else if(get.size()>ans.size()) ans=get;
	}

	cout << ans << endl;
	
}

int main(){
	// error_txt();
	ios_base::sync_with_stdio(0); cin.tie(0);
	ll t=1;
	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:35:14
Judged At
2024-11-11 03:11:19
Judged By
Score
100
Total Time
5ms
Peak Memory
808.0 KiB