Submission #59865604


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<char> vchar;
typedef vector <pair<ll, ll>> vp;
typedef pair<ll, ll> pll;
typedef map <ll, ll> mll;
typedef set <ll> sll;
#define pb push_back
#define ff first
#define ss second
#define str to_string
#define all(x) (x).begin(), (x).end()
#define print(x) for (auto i : x) cout << i << ' '; cout << '\n';
#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define TxtIO freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<char> vchar;
typedef vector <pair<ll, ll>> vp;
typedef pair<ll, ll> pll;
typedef map <ll, ll> mll;
typedef set <ll> sll;
#define pb push_back
#define ff first
#define ss second
#define str to_string
#define all(x) (x).begin(), (x).end()
#define print(x) for (auto i : x) cout << i << ' '; cout << '\n';
#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define TxtIO freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);

const ll maxn = 3*1e6+5;
const ll mod = 1e9+7;
const ll inf = 1e12;

ll pw(ll a, ll b, ll M = mod) {ll ans = 1; for (; b; a = ((a * a) % M), b >>= 1) if (b & 1) ans = (ans * a) % M; return ans;}

ll n, q, t, x, c;
ll cnt[maxn];

int main() {
    cin >> n >> q;
    set <pll> st;
    for (ll i = 1; i <= n; i++) {
        cnt[i] = 1;
        st.insert({i, i});
    }

    st.insert({n+1, 0});

    while (q--) {
        cin >> t;
        if (t == 1) {
            cin >> x >> c;

            auto it = st.upper_bound({x, inf});
            auto it2 = st.upper_bound({x, inf});
            it2--;

            if ((*it2).ss != c) {
                ll f = (*it2).ff;
                cnt[(*it2).ss] -= (it)->ff - (it2)->ff;
                cnt[c] += (it)->ff - (it2)->ff;
                st.erase(it2);
                st.insert({f, c});
                if ((it)->ss == c) {
                    st.erase(it);
                }
                auto it3 = it2;
                if (it3 != st.begin()) {
                    it3--;
                    if ((it3)->ss == c) {
                        st.erase(it2);
                    }
                }
            }

//            cout << (it2)->ff << ' ' << (it)->ff << '\n';
//            for (ll i = 1; i <= n; i++) cout << cnt[i] << ' ';cout << '\n';

        } else {
            cin >> c;
            cout << cnt[c] << '\n';
        }


    }

    return 0;
}

Submission Info

Submission Time
Task E - 1D Bucket Tool
User SinaSP
Language C++ 20 (gcc 12.2)
Score 0
Code Size 2067 Byte
Status RE
Exec Time 2207 ms
Memory 38764 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 450
Status
AC × 1
AC × 10
WA × 1
TLE × 1
RE × 6
Set Name Test Cases
Sample sample_01.txt
All hand.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, sample_01.txt
Case Name Status Exec Time Memory
hand.txt AC 1 ms 3448 KB
random_01.txt AC 143 ms 3440 KB
random_02.txt AC 202 ms 3532 KB
random_03.txt TLE 2207 ms 3332 KB
random_04.txt RE 148 ms 3268 KB
random_05.txt RE 174 ms 38448 KB
random_06.txt WA 282 ms 38688 KB
random_07.txt AC 278 ms 38688 KB
random_08.txt AC 404 ms 38688 KB
random_09.txt AC 402 ms 38696 KB
random_10.txt AC 409 ms 38764 KB
random_11.txt AC 397 ms 38680 KB
random_12.txt AC 404 ms 38696 KB
random_13.txt RE 85 ms 6748 KB
random_14.txt RE 88 ms 6776 KB
random_15.txt RE 90 ms 6784 KB
random_16.txt RE 86 ms 6800 KB
sample_01.txt AC 1 ms 3500 KB


2025-03-05 (Wed)
12:33:06 +00:00