提出 #41542299


ソースコード 拡げる

// Om Namah Shivaya

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define pb push_back
#define endl '\n'
#define sz(a) a.size()
#define setbits(x) __builtin_popcountll(x)
#define ff first
#define ss second
#define conts continue
#define ceil2(x, y) ((x + y - 1) / (y))
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define yes cout << "Yes" << endl
#define no cout << "No" << endl

#define rep(i, n) for(int i = 0; i < n; ++i)
#define rep1(i, n) for(int i = 1; i <= n; ++i)
#define rev(i, s, e) for(int i = s; i >= e; --i)
#define trav(i, a) for(auto &i : a)

template<typename T>
void amin(T &a, T b) {
    a = min(a, b);
}

template<typename T>
void amax(T &a, T b) {
    a = max(a, b);
}

#ifdef LOCAL
#include "debug.h"
#else
#define debug(x) 42
#endif

/*



*/

const int MOD = 1e9 + 7;
const int N = 3e5 + 5;
const int inf1 = int(1e9) + 5;
const ll inf2 = ll(1e18) + 5;

set<ll> adj[N];

void solve(int test_case)
{
    ll n, q; cin >> n >> q;
    vector<ll> deg(n + 5);
    ll good = n;

    while (q--) {
        ll t; cin >> t;
        if (t == 1) {
            ll u, v; cin >> u >> v;
            if (!deg[u]) good--;
            if (!deg[v]) good--;
            deg[u]++, deg[v]++;
            adj[u].insert(v), adj[v].insert(u);
        }
        else {
            ll u; cin >> u;
            if (deg[u]) {
                trav(v, adj[u]) {
                    adj[v].erase(u);
                    deg[v]--;
                    if (!deg[v]) good++;
                }

                adj[u].clear();
                deg[u] = 0;
                good++;
            }
        }

        cout << good << endl;
    }
}

int main()
{
    fastio;

    int t = 1;
    // cin >> t;

    rep1(i, t) {
        solve(i);
    }

    return 0;
}

提出情報

提出日時
問題 E - Isolation
ユーザ Superposition
言語 C++ (GCC 9.2.1)
得点 425
コード長 2268 Byte
結果 AC
実行時間 383 ms
メモリ 47868 KiB

コンパイルエラー

./Main.cpp: In function ‘void solve(int)’:
./Main.cpp:64:16: warning: unused parameter ‘test_case’ [-Wunused-parameter]
   64 | void solve(int test_case)
      |            ~~~~^~~~~~~~~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 425 / 425
結果
AC × 2
AC × 35
セット名 テストケース
Sample example_00.txt, example_01.txt
All example_00.txt, example_01.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, random_00.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, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt
ケース名 結果 実行時間 メモリ
example_00.txt AC 27 ms 17544 KiB
example_01.txt AC 16 ms 17540 KiB
hand_00.txt AC 350 ms 47868 KiB
hand_01.txt AC 240 ms 33812 KiB
hand_02.txt AC 245 ms 33816 KiB
hand_03.txt AC 82 ms 19480 KiB
hand_04.txt AC 68 ms 19516 KiB
hand_05.txt AC 135 ms 33816 KiB
hand_06.txt AC 225 ms 33880 KiB
hand_07.txt AC 249 ms 33668 KiB
random_00.txt AC 93 ms 19824 KiB
random_01.txt AC 129 ms 19460 KiB
random_02.txt AC 51 ms 19824 KiB
random_03.txt AC 141 ms 21520 KiB
random_04.txt AC 159 ms 19788 KiB
random_05.txt AC 240 ms 38300 KiB
random_06.txt AC 239 ms 31024 KiB
random_07.txt AC 163 ms 20020 KiB
random_08.txt AC 370 ms 46120 KiB
random_09.txt AC 364 ms 45164 KiB
random_10.txt AC 48 ms 19804 KiB
random_11.txt AC 93 ms 24224 KiB
random_12.txt AC 67 ms 19736 KiB
random_13.txt AC 99 ms 21688 KiB
random_14.txt AC 270 ms 31452 KiB
random_15.txt AC 53 ms 20632 KiB
random_16.txt AC 119 ms 26420 KiB
random_17.txt AC 249 ms 32292 KiB
random_18.txt AC 112 ms 23016 KiB
random_19.txt AC 280 ms 34536 KiB
random_20.txt AC 231 ms 32936 KiB
random_21.txt AC 104 ms 24224 KiB
random_22.txt AC 281 ms 32872 KiB
random_23.txt AC 383 ms 45984 KiB
random_24.txt AC 263 ms 39252 KiB