/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Accepted 9ms 5.34 MiB
#3 Accepted 9ms 4.754 MiB
#4 Accepted 7ms 4.695 MiB
#5 Accepted 9ms 4.719 MiB
#6 Accepted 7ms 4.809 MiB
#7 Accepted 5ms 2.52 MiB
#8 Accepted 2ms 512.0 KiB
#9 Accepted 2ms 508.0 KiB
#10 Accepted 5ms 2.715 MiB
#11 Accepted 2ms 320.0 KiB
#12 Accepted 3ms 928.0 KiB
#13 Accepted 4ms 788.0 KiB
#14 Accepted 3ms 796.0 KiB
#15 Accepted 5ms 2.496 MiB

Code

#include<bits/stdc++.h>
using namespace std;
using ll=long long int;

void fastio(){ios::sync_with_stdio(false);cin.tie(0);}

vector<ll> take_inputs_0(ll n){vector<ll> v(n);for(int i=0;i<n;i++){cin>>v[i];}return v;}
vector<ll> take_inputs_1(ll n){vector<ll> v(n);for(int i=1;i<n;i++){cin>>v[i];}return v;}

void show(auto x){ cout<<x<<"\n";}
void show1(auto v){ ll n=(signed)v.size();for(int i=0;i<n;i++){cout<<v[i]<<" ";}cout<<"\n";}
void show2(auto v){ ll n=(signed)v.size();for(int i=0;i<n;i++){	cout<<v[i]<<"\n";}}

void sort_it(auto &v){ sort(v.begin(),v.end());}
void reverse_it(auto &v){ reverse(v.begin(),v.end());}
void do_both(auto &v){ sort(v.begin(),v.end());reverse(v.begin(),v.end());}

auto find_max(auto v){ sort(v.begin(),v.end());reverse(v.begin(),v.end());return v[0];}
auto find_min(auto v){ sort(v.begin(),v.end());return v[0];}

vector<ll> bitRep64(ll n){vector<ll> v;int i=0;while(i<=63){if(n&(1LL<<i)){v.push_back(1);}else{v.push_back(0);}i++;}return v;}
vector<ll> bitRep32(ll n){vector<ll> v;int i=0;while(i<=31){if(n&(1LL<<i)){v.push_back(1);}else{v.push_back(0);}i++;}return v;}
vector<string> all_subset(ll n){vector<string> v;for(int i=0;i<(1<<n);i++){string st="";for(int j=0;j<n;j++){if(i&(1<<j)){st+="1";}else{st+="0";}}v.push_back(st);}return v;}

vector<ll> prefix_sum_0(vector<ll> v){ll n=(signed)v.size();for(int i=1;i<n;i++){v[i]=v[i-1]+v[i];}return v;}
vector<ll> prefix_sum_1(vector<ll> v){ll n=(signed)v.size();vector<ll> summ(n+1);for(int i=1;i<=n;i++){summ[i]=summ[i-1]+v[i-1];}return summ;}

///////////////////////////////////

int main()
{
	int t;cin>>t;
	
	while(t--)
	{
		ll n;cin>>n;
		ll k;cin>>k;
		
		vector<string> v(n);
		
		for(int i=0;i<n;i++)
		{
			cin>>v[i];
		}
		
		vector<string> ans;
		
		for(int i=0;i<n-k;i++)
		{
			string st="";
			for(int j=i;j<i+k+1 && j<n;j++)
			{
				st+=v[j];
			}
			
			ans.push_back(st);
		}
		
		sort_it(ans);
		
		
		string st="";
		
		ll len=0;
		
		len=ans[0].size();
		
		
		vector<string> res;
		
		
		
		for(int i=1;i<ans.size();i++)
		{
			if(len<ans[i].size())
			{
				len=ans[i].size();
			}
		}
		
		
		for(int i=0;i<ans.size();i++)
		{
			if(ans[i].size()==len)
			{
				res.push_back(ans[i]);
			}
		}
		
		sort_it(res);
		
		len=res.size()-1;
		
		
		show(res[len]);
		
		
	}
	
	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:17:03
Judged At
2024-11-11 03:15:20
Judged By
Score
100
Total Time
9ms
Peak Memory
5.34 MiB