/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB

Code

//....................................<In the name of Allah>...............................//

//.................................<b_bitsmillahir Rahmanir Rahim>...................................//
// Author : Riaj Udd_bitn

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<ll, nll_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> pii;
typedef pair<double, double> pdd;

typedef double dl;

#define lower(a, b) lower_bound((a).begin(), (a).end(), b) - (a).begin()
#define mem(a, b) memset(a, b, sizeof(a));

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

#define fraction(a)               \
    cout.unsetf(ios::floatfield); \
    cout.precision(a);            \
    cout.setf(ios::fined, ios::floatfield);
//////////////////////////////////////////

///////////bit-manipulation///////////////
#define Mb(msk) 63 - __builtin_clzll(msk)
#define Lb(msk) __builtin_ctzll(msk)
#define ONE(msk) __builtin_popkll(msk)
#define CHECK(msk, bit) (msk & (1LL << bit))
#define ON(msk, bit) (msk | (1LL << bit))
#define Off(msk, bit) (msk & ~(1LL << bit))
#define CHANGE(msk, bit) (msk ^ (1LL << bit))

//////////////
const ll MOD = 1e9 + 7;
inline void normal(ll &a)
{
    a %= MOD;
    (a < 0) && (a += MOD);
}
inline ll modMul(ll a, ll b)
{
    a %= MOD, b %= MOD;
    normal(a), normal(b);
    return (a * b) % MOD;
}
inline ll modAdd(ll a, ll b)
{
    a %= MOD, b %= MOD;
    normal(a), normal(b);
    return (a + b) % MOD;
}
inline ll modSub(ll a, ll b)
{
    a %= MOD, b %= MOD;
    normal(a), normal(b);
    a -= b;
    normal(a);
    return a;
}
inline ll modPow(ll b, ll p)
{
    ll r = 1;
    while (p)
    {
        if (p & 1)
            r = modMul(r, b);
        b = modMul(b, b);
        p >>= 1;
    }
    return r;
}
inline ll modInverse(ll a) { return modPow(a, MOD - 2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

// std::ofstream outputFile("C:/Users/Asus/Desktop/New folder/output.txt");

void solve()
{
    ll n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    for (int i = 0; i < s.size();)
    {
        if (i && s[i] > s[i - 1] && k)
        {
            s.erase(s.begin() + i - 1);
            i--;
            k--;
            continue;
        }
        i++;
    }
    while (k--)
        s.pop_back();
    if (s.size() == 0)
        cout << 0;
    else
        cout << s;

    cout << "\n";
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    ll t = 1;
    cin >> t;
    for (ll tc = 1; tc <= t; tc++)
        solve();
}

Information

Submit By
Type
Submission
Problem
P1006 Remove K Digits
Language
C++17 (G++ 13.2.0)
Submit At
2024-11-03 05:13:29
Judged At
2024-11-03 05:13:29
Judged By
Score
100
Total Time
1ms
Peak Memory
540.0 KiB