/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 336.0 KiB
#2 Accepted 5ms 532.0 KiB
#3 Accepted 5ms 612.0 KiB
#4 Accepted 3ms 844.0 KiB
#5 Accepted 3ms 580.0 KiB
#6 Accepted 3ms 580.0 KiB
#7 Accepted 3ms 532.0 KiB
#8 Accepted 1ms 532.0 KiB
#9 Accepted 1ms 532.0 KiB
#10 Accepted 3ms 488.0 KiB
#11 Accepted 1ms 320.0 KiB
#12 Accepted 2ms 532.0 KiB
#13 Accepted 3ms 436.0 KiB
#14 Accepted 3ms 600.0 KiB
#15 Accepted 3ms 580.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 2e5 + 10;
const ll MOD = 1e9 + 7;

string mx(string a, string b) {
  if(a.size() > b.size()) return a;
  if(a.size() < b.size()) return b;

  for(int i = 0; i < a.size(); i++) {
    if(a[i] > b[i]) return a;
    if(a[i] < b[i]) return b;
  }
  return a;
}
void solve()
{
  ll n, k;
  cin >> n >> k;
  vector<string>v(n);
  for(ll i = 0; i < n; i++) {
    cin >> v[i];
  }
  string ans = "";
  for(ll i = 0; i < (n - k); i++) {
    string temp = "";
    for(ll j = i; j <= (i + k); j++) {
      temp += v[j];
    }
    ans = mx(ans, temp);
  }

  cout << ans << "\n";
}

int main()
{
  ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);

  int t;
  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:32:51
Judged At
2024-10-03 13:26:43
Judged By
Score
100
Total Time
5ms
Peak Memory
844.0 KiB