/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 540.0 KiB
#2 Accepted 9ms 484.0 KiB
#3 Accepted 8ms 596.0 KiB
#4 Accepted 5ms 596.0 KiB
#5 Accepted 5ms 488.0 KiB
#6 Accepted 5ms 596.0 KiB
#7 Accepted 5ms 412.0 KiB
#8 Accepted 3ms 564.0 KiB
#9 Accepted 3ms 496.0 KiB
#10 Accepted 5ms 540.0 KiB
#11 Accepted 3ms 496.0 KiB
#12 Accepted 4ms 568.0 KiB
#13 Accepted 5ms 580.0 KiB
#14 Accepted 4ms 580.0 KiB
#15 Accepted 5ms 588.0 KiB

Code

// I AM A MUSLIM

#include "bits/stdc++.h"

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")

#define fastIO std::ios::sync_with_stdio(0);std::cin.tie(0)
#define ll long long int
#define flush fflush(stdout)
#define bl printf("\n")
#define yn(a, b) printf("%s\n", a >= b ? "Yes":"No")
// #define int ll

using pii = std::pair<int,int>;

const int MOD = 1000000007;
// const int MOD = 998244353;
const int mxN = 100100;

std::string calc(std::string a, std::string b) {
    if ((int)a.size() > (int)b.size()) return a;
    if ((int)a.size() < (int)b.size()) return b;
    for (int i = 0; i < (int)a.size(); i++) {
        if (a[i] > b[i]) return a;
        if (b[i] > a[i]) return b;
    }
    return a;
}

signed main() {
    // fastIO;
    int testCases=1;
    scanf("%d",&testCases);
    // std::cin>>testCases;
    
    for (int TC = 1; TC <= testCases; TC++) {
        int N, k;
        scanf("%d%d",&N,&k);
        std::vector<std::string> a(N);
        for (auto &i : a) std::cin >> i;
        
        std::string ans;
        for (int i = 0; i+k < N; i++) {
            std::string s;
            for (int j = i, c = 0; c <= k; c++,j++) {
                s += a[j];
            }
            ans = calc(ans, s);
        }
        
        printf("%s\n", ans.c_str());
        
    }
    
    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:24:42
Judged At
2024-10-03 13:22:08
Judged By
Score
100
Total Time
9ms
Peak Memory
596.0 KiB