/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Accepted 3ms 580.0 KiB
#3 Accepted 3ms 576.0 KiB
#4 Accepted 3ms 576.0 KiB
#5 Accepted 3ms 576.0 KiB
#6 Accepted 3ms 576.0 KiB
#7 Accepted 3ms 576.0 KiB
#8 Accepted 2ms 576.0 KiB
#9 Accepted 2ms 320.0 KiB
#10 Accepted 3ms 532.0 KiB
#11 Accepted 2ms 512.0 KiB
#12 Accepted 2ms 580.0 KiB
#13 Accepted 3ms 596.0 KiB
#14 Accepted 3ms 592.0 KiB
#15 Accepted 3ms 604.0 KiB

Code

#include <iostream>
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define pb push_back
#define vi vector<int>
#define vll vector<ll>
#define mp make_pair
#define pq priority_queue<int>
#define pi pair<int, int>
#define pll pair<ll, ll>
#define all(x) (x).begin(), (x).end()
#define f(i, n) for (int i = 0; i < n; i++)
#define PI acos(-1)
const int M = 1e9 + 7;
ll binExp(ll a, ll b)
{
    int res = 1;
    while (b)
    {
        if (b & 1)
            res = res * a;
        a *= a;
        b /= 2;
    }
    return res;
}
ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
ll lcm(ll a, ll b)
{
    return (a / gcd(a, b)) * b;
}
void solve()
{
    ll n, k;
    cin >> n >> k;
    k++;
    vector<string> v(n);
    for (int i = 0; i < n; i++)
        cin >> v[i];
    string mx = "";
    for (int i = 0; i <= n - k; i++)
    {
        string temp = "";
        for (int j = i, c = 0; c < k; c++, j++)
        {
            temp += v[j];
        }
        if (temp.size() > mx.size() or temp.size() == mx.size() and temp > mx)
            mx = temp;
        // cout << temp << ' ' << mx << '\n';
    }
    cout << mx << '\n';
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    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 16:25:59
Judged At
2024-11-11 03:14:48
Judged By
Score
100
Total Time
3ms
Peak Memory
604.0 KiB