結果

問題 No.3390 Public or Private
コンテスト
ユーザー a01sa01to
提出日時 2025-12-02 00:57:31
言語 C++23
(gcc 13.3.0 + boost 1.89.0)
結果
TLE  
実行時間 -
コード長 784 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,130 ms
コンパイル使用メモリ 285,468 KB
実行使用メモリ 32,256 KB
最終ジャッジ日時 2025-12-02 00:58:03
合計ジャッジ時間 30,928 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23 TLE * 4
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  map<int, set<int>> fl;
  rep(_, m) {
    int u, v;
    cin >> u >> v;
    fl[v].insert(u);
  }
  set<int> priv;
  int q;
  cin >> q;
  while (q--) {
    int t, a, b;
    cin >> t >> a >> b;
    if (t == 1) {
      if (fl[b].contains(a))
        fl[b].erase(a);
      else
        fl[b].insert(a);
    }
    if (t == 2) {
      if (priv.contains(a))
        priv.erase(a);
      else
        priv.insert(a);
    }
    int ans = n - 1;
    for (int x : priv)
      if (x != a && !fl[x].contains(a)) --ans;
    cout << ans << '\n';
  }
  return 0;
}
0