/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 5ms 3.027 MiB
#3 Accepted 5ms 2.754 MiB
#4 Accepted 6ms 2.781 MiB
#5 Accepted 4ms 2.785 MiB
#6 Accepted 4ms 2.777 MiB
#7 Accepted 4ms 2.777 MiB
#8 Accepted 2ms 796.0 KiB
#9 Accepted 1ms 492.0 KiB
#10 Accepted 5ms 2.758 MiB
#11 Accepted 1ms 540.0 KiB
#12 Accepted 2ms 796.0 KiB
#13 Accepted 3ms 1008.0 KiB
#14 Accepted 3ms 796.0 KiB
#15 Accepted 4ms 2.527 MiB

Code

#include <bits/stdc++.h>
using namespace std;
#define SC               scanf
#define PF               printf
#define ull              unsigned long long
#define ld               long double
#define F                first
#define S                second
#define pb               push_back
#define sort_a(a)        sort(a.begin(),a.end());
#define sort_d(a)        sort(a.rbegin(),a.rend());
#define READ(f)          freopen(f, "r", stdin)
#define WRITE(f)         freopen(f, "w", stdout)
#define rev(s)           reverse(s.begin(),s.end())
#define P(ok)            cout << (ok ? "YES\n": "NO\n")
#define __Heart__              ios_base :: sync_with_stdio(false); cin.tie(NULL);
#define ll long long
typedef pair< ll , ll>                   PII;

bool compare (pair < string , int >& a , pair < string , int >& b){
   if(a.S == b.S) return a.F > b.F ;
   else return a.S > b.S ;
}
void solve()
{
    int n , k; cin >> n >> k ;
    vector < string > v(n) ;
    vector < pair < string , int > > arr ;
    for(auto &x : v) cin >> x ;
    string Ans = "" ;
    for(int i = 0 ; i < n - k ; i++){
        int j = i ;
        string cur = "" ;
        while(j <= i + k){
            cur += v[j] ;
            j++ ;
        }
        arr.pb({cur , cur.size()}) ;
    }
    sort(arr.begin() , arr.end() , compare) ;
    cout << arr[0].F << "\n" ;
}
int main()
{
     __Heart__
     int t ; cin >> t ; while(t--) solve() ;
}

Information

Submit By
Type
Submission
Problem
P1083 Number concatenation
Language
C++20 (G++ 13.2.0)
Submit At
2024-08-09 00:54:16
Judged At
2024-08-09 00:54:16
Judged By
Score
100
Total Time
6ms
Peak Memory
3.027 MiB