/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 524.0 KiB
#2 Accepted 10ms 604.0 KiB
#3 Accepted 10ms 604.0 KiB
#4 Accepted 10ms 604.0 KiB
#5 Accepted 11ms 604.0 KiB
#6 Accepted 15ms 604.0 KiB
#7 Accepted 8ms 620.0 KiB
#8 Accepted 2ms 584.0 KiB
#9 Accepted 2ms 580.0 KiB
#10 Accepted 6ms 616.0 KiB
#11 Accepted 2ms 560.0 KiB
#12 Accepted 3ms 584.0 KiB
#13 Accepted 6ms 596.0 KiB
#14 Accepted 5ms 596.0 KiB
#15 Accepted 6ms 616.0 KiB

Code

#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define all(a) a.begin(),a.end()
#define endl '\n'
 typedef pair<int, int> pi; 

void solve()
{
        ll n,k;cin>>n>>k;
        vector<string>v(n);
        for(auto &c:v)cin>>c;

        string mx="0";
        string tmp;
        ll ct;
        for(ll i=0;i<n;i++)
        {
            tmp="";
            ct=k+1;
            ll j=i;
            while(ct--)
            {
                if(j==n)break;
                tmp+=v[j];
                j++;

            }
           ll det=1;
           ll det2=0;

           if(mx.size()<tmp.size())det=0;
           else if(mx.size()==tmp.size())
           {
                for(ll i=0;i<mx.size();i++)
                {
                    if(mx[i]>tmp[i]&&det2==0)
                    {
                        det2=1;
                    }
                    if(mx[i]<tmp[i]&&det2==0)
                    {
                        det=0;
                    }
                   
                }
           }
           if(!det)
           {
            mx=tmp;
           }
           

        }
        cout<<mx<<endl;

}

int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    ll t=1;cin>>t;
    while(t--)
    {
      solve();
    }    
}

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:03:09
Judged At
2024-10-03 13:28:53
Judged By
Score
100
Total Time
15ms
Peak Memory
620.0 KiB