Submission #56536801


Source Code Expand

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define _GLIBCXX_DEBUG
// kyopuro2.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cassert>
#include <bitset>
#include <sstream>
#include <stdlib.h>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define eb emplace_back

const long long INF = 1LL << 60;
const long long MOD = 998244353;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

using db = double;
using ll = long long;
using ldb = long double;
using ch = char;
using st = string;
using vi = vector<int>;
using vll = vector<ll>;
using vb = vector<bool>;
using vc = vector<ch>;
using vs = vector<st>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvc = vector<vc>;
using vvs = vector<vs>;
using vvll = vector<vll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using vP = vector <P>;
using vPll = vector<Pll>;
using p_qi = priority_queue<int>;

// 深さ優先探索
vector<bool> seen(300009, false);
vi L(300009,-1);
vi S(300009.-1);
vi fo;
vi lo;
void dfs(const vi& G, int v,int& fp,int&lp) {
    fo[v] = fp++;
    seen[v] = true; // v を訪問済にする
    // v から行ける各頂点 next_v について

    if (!(seen[G[v]])) {
        dfs(G, G[v], fp, lp); // 再帰的に探索
    }
    if (seen[G[v]]) {
        if (S[G[v]] > 0) {
            L[v] = L[G[v]] + 1;
            S[v] = S[G[v]];
        }
        else {
            S[v] = fo[v] - fo[G[v]] + 1;
            cout << S[v] << "\n";
            L[v] = 1;
        }
    }

    lo[v] = lp++;
}
template< typename T >
T mod_pow(T x, T n, const T& p) {
    T ret = 1;
    while (n > 0) {
        if (n & 1) (ret *= x) %= p;
        (x *= x) %= p;
        n >>= 1;
    }
    return ret;
}
int dx[] = { -1,0,1,0 }; int dy[] = { 0,1,0,-1 };
char ldru[] = { 'L','D','R','U' };
ll dp[200009][2][2];
ll GetDigit(ll num) {
    return to_string(num).length();
}


int binary(int bina) {
    int ans = 0;
    for (int i = 0; bina > 0; i++)
    {
        ans = ans + (bina % 2) * pow(10, i);
        bina = bina / 2;
    }
    return ans;
}

int main() {
    ll Q;
    cin >> Q;
    vi B(1000006,0);
    int kind = 0;
    rep(i, Q) {
        int w;
        cin >> w;
        if (w == 3) {
            cout << kind << "\n";
        }
        else {
            int x;
            cin >> x;
            if (w == 1) {
                if (B[x] == 0) {
                    kind++;
                }
                B[x]++;
            }
            else {
                if(B[x] == 1){
                    kind--;
                }
                B[x]--;
            }
        }
    }
    
}


// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Submission Info

Submission Time
Task C - Balls and Bag Query
User michael_80
Language C++ 20 (gcc 12.2)
Score 300
Code Size 4472 Byte
Status AC
Exec Time 142 ms
Memory 9556 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 2
AC × 25
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt
All 00_sample_00.txt, 00_sample_01.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 3 ms 9424 KiB
00_sample_01.txt AC 3 ms 9532 KiB
01_random_00.txt AC 119 ms 9552 KiB
01_random_01.txt AC 117 ms 9524 KiB
01_random_02.txt AC 117 ms 9488 KiB
01_random_03.txt AC 115 ms 9420 KiB
01_random_04.txt AC 115 ms 9484 KiB
01_random_05.txt AC 116 ms 9516 KiB
01_random_06.txt AC 115 ms 9540 KiB
01_random_07.txt AC 117 ms 9500 KiB
01_random_08.txt AC 115 ms 9504 KiB
01_random_09.txt AC 115 ms 9520 KiB
01_random_10.txt AC 140 ms 9492 KiB
01_random_11.txt AC 140 ms 9556 KiB
01_random_12.txt AC 140 ms 9556 KiB
01_random_13.txt AC 140 ms 9424 KiB
01_random_14.txt AC 141 ms 9308 KiB
01_random_15.txt AC 140 ms 9556 KiB
01_random_16.txt AC 141 ms 9556 KiB
01_random_17.txt AC 142 ms 9496 KiB
01_random_18.txt AC 59 ms 9312 KiB
01_random_19.txt AC 136 ms 9428 KiB
01_random_20.txt AC 99 ms 9532 KiB
01_random_21.txt AC 98 ms 9520 KiB
01_random_22.txt AC 98 ms 9428 KiB