/ SeriousOJ /

Record Detail

Runtime Error


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 532.0 KiB
#2 Runtime Error terminate called after throwing an instance of 'std::out_of_range' what(): stoi 2ms 580.0 KiB
#3 Runtime Error terminate called after throwing an instance of 'std::out_of_range' what(): stoi 2ms 580.0 KiB
#4 Runtime Error terminate called after throwing an instance of 'std::out_of_range' what(): stoi 2ms 572.0 KiB
#5 Runtime Error terminate called after throwing an instance of 'std::out_of_range' what(): stoi 2ms 576.0 KiB
#6 Runtime Error terminate called after throwing an instance of 'std::out_of_range' what(): stoi 2ms 696.0 KiB
#7 Runtime Error terminate called after throwing an instance of 'std::out_of_range' what(): stoi 2ms 576.0 KiB
#8 Runtime Error terminate called after throwing an instance of 'std::out_of_range' what(): stoi 2ms 576.0 KiB
#9 Runtime Error terminate called after throwing an instance of 'std::out_of_range' what(): stoi 2ms 576.0 KiB
#10 Runtime Error terminate called after throwing an instance of 'std::out_of_range' what(): stoi 2ms 636.0 KiB
#11 Wrong Answer 2ms 324.0 KiB
#12 Wrong Answer 16ms 836.0 KiB
#13 Wrong Answer 47ms 1.902 MiB
#14 Wrong Answer 31ms 1.125 MiB
#15 Runtime Error terminate called after throwing an instance of 'std::out_of_range' what(): stoi 2ms 636.0 KiB

Code

#include <bits/stdc++.h>
#include <cmath>
#include <bitset>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>pbds;
#define ll  long long  int
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define    gcd(a,b)         __gcd(a,b)
#define    lcm(a,b)        ((a*b)/gcd(a,b))
#define    pi               acos(-1.00)
const int mod=1000000007;
void evan() {
 ll n,k;
 cin>>n>>k;
 vector<string>v;
 for(int i=0;i<n;i++){
   string s;
   cin>>s;
   v.push_back(s);
 }
 map<ll,string>m;
 for(int i=0;i<n;i++){
    ll l=i,r=i;
   for(int j=0;j<k;j++){
       if(l==0){
         r++;
       }
       else if(r==n-1){
         l--;
       }
       else{
           string ss;
           ss+=v[i];ss+=v[r];
           string sss;sss+=v[i];sss+=v[l];
           ll xx=stoi(ss);
           ll xxx=stoi(sss);
           if(xx>=xxx) r++;
           else l--;
       }
   }
   
   string s;
   for(int j=l;j<=r;j++){
      s+=v[j];
   }
  
   m[i]=s;
 }
 string s=m[0];
 for(int i=1;i<n;i++){
    if(m[i]>s)s=m[i];
 }
 cout<<s<<"\n";
}
signed main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(nullptr);
   int t=1;
   cin>>t;
  for(int i=1;i<=t;i++) evan();
}

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:04:19
Judged At
2024-10-03 13:24:20
Judged By
Score
5
Total Time
47ms
Peak Memory
1.902 MiB