結果
| 問題 | No.3390 Public or Private |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-12-19 16:28:14 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 1,625 ms / 2,000 ms |
| コード長 | 627 bytes |
| 記録 | |
| コンパイル時間 | 3,635 ms |
| コンパイル使用メモリ | 288,068 KB |
| 実行使用メモリ | 32,128 KB |
| 最終ジャッジ日時 | 2025-12-19 16:28:37 |
| 合計ジャッジ時間 | 22,039 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(void) {
int N, M;
cin >> N >> M;
map<int, set<int>> G;
while(M--) {
int u, v;
cin >> u >> v;
--u, --v;
G[u].insert(v);
}
set<int> s;
int Q;
cin >> Q;
while(Q--) {
int cmd, a, b;
cin >> cmd >> a >> b;
--a, --b;
if(cmd == 1) {
if(G[a].find(b) == G[a].end()) G[a].insert(b);
else G[a].erase(b);
}
if(cmd == 2) {
if(s.find(a) == s.end()) s.insert(a);
else s.erase(a);
}
int ans = N - 1 - (int)s.size();
for(auto v : s) if(G[a].find(v) != G[a].end() or v == a) ans += 1;
cout << ans << "\n";
}
return 0;
}