0pts 求调
查看原帖
0pts 求调
961351
nightwatch.ryan楼主2024/10/4 09:33

rt

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

#define P(i, a, b) for(int i = a; i <= b; i++)
#define Q(i, a, b) for(int i = a; i >= b; i--)
const int maxn = 100005;
const int inf = 0x3f3f3f3f;

mt19937 rnd(chrono::duration_cast<chrono::nanoseconds>
           (chrono::system_clock::now().time_since_epoch()).count());
int randint(int L, int R) {
    uniform_int_distribution<int> dist(L, R);
    return dist(rnd);
}

signed main(){

    cin.tie(0)->sync_with_stdio(0);
    int q;
    cin >> q;
    map<int, pair<int, int>> m;
    int ti = 0, now = 1;
    while(q --){
        int op, x, y;
        cin >> op;
        if(op == 1){
            cin >> x >> y;
            if(m[x].first == ti - 1){
                if(m[x].second >= 1){
                    m[x].second = 1;
                }
            }
            m[x].second += y;
            m[x].first = now;
        }else if(op == 2){
            cin >> x >> y;
            if(m[x].first == ti - 1){
                if(m[x].second >= 1){
                    m[x].second = 1;
                }
            }
            m[x].second = max(m[x].second - y, 0ll);
            m[x].first = now;
        }else if(op == 3){
            ti = now;
        }else{
            cin >> x;
            if(m[x].first == ti - 1){
                if(m[x].second >= 1){
                    m[x].second = 1;
                }
            }
            cout << m[x].second << endl;
            m[x].first = now;
        }
        now ++;
    }

}
2024/10/4 09:33
加载中...