/ SeriousOJ /

Record Detail

Runtime Error


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 532.0 KiB
#2 Accepted 6ms 580.0 KiB
#3 Accepted 6ms 612.0 KiB
#4 Wrong Answer 4ms 612.0 KiB
#5 Accepted 4ms 580.0 KiB
#6 Wrong Answer 3ms 576.0 KiB
#7 Wrong Answer 3ms 580.0 KiB
#8 Wrong Answer 2ms 580.0 KiB
#9 Wrong Answer 2ms 324.0 KiB
#10 Wrong Answer 3ms 576.0 KiB
#11 Runtime Error 2ms 536.0 KiB
#12 Wrong Answer 2ms 532.0 KiB
#13 Wrong Answer 2ms 484.0 KiB
#14 Wrong Answer 2ms 580.0 KiB
#15 Wrong Answer 3ms 536.0 KiB

Code

/**
 *  written by Binoy Barman .
**/

#include<bits/stdc++.h>
using namespace std;
#define nl '\n'
#define all(v) v.begin(), v.end()
#define Too_Many_Jobs int tts, tc = 1; cin >> tts; hell: while(tts--)
#define Dark_Lord_Binoy ios_base::sync_with_stdio(false); cin.tie(NULL);

#ifdef LOCAL
#include "unravel.hpp"
#else
#define dbg(...) 42
#endif
#define int long long

bool check(string &a, string &b) {
    if(a.length() < b.length()) return true;
    if(a.length() > b.length()) return false;
    for (int i = 0; i < a.length(); i++) {
        if(a[i] < b[i]) return true;
        else if(a[i] > b[i]) return false;
    }
    return false;
}

int32_t main() {
Dark_Lord_Binoy
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    Too_Many_Jobs {
        int n, k;
        cin >> n >> k;
        vector<string> a(n);
        string mx = "";
        for (int i = 0; i < n; i++) {
            cin >> a[i];
            if(i <= k) {
                for(auto c : a[i]) mx.push_back(c);
            }
        }
        string pre = mx;
        for (int i = 1; i < n; i++) {
            if(i + k >= n) break;
            string cur = pre;
            reverse(all(cur));
            for (int j = 0; j < a[i - 1].length(); j++) {
                cur.pop_back();
            }
            reverse(all(cur));
            for(auto c : a[i + k]) cur.push_back(c);
            if(check(mx, cur)) swap(mx, cur);
            pre = cur;
        }
        cout << mx << nl;
    }

    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 15:58:39
Judged At
2024-10-03 13:29:15
Judged By
Score
20
Total Time
6ms
Peak Memory
612.0 KiB