結果
| 問題 | No.3390 Public or Private |
| コンテスト | |
| ユーザー |
yt142857
|
| 提出日時 | 2025-11-21 10:00:18 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 965 ms / 2,000 ms |
| コード長 | 776 bytes |
| コンパイル時間 | 289 ms |
| コンパイル使用メモリ | 82,116 KB |
| 実行使用メモリ | 88,952 KB |
| 最終ジャッジ日時 | 2025-11-28 20:57:35 |
| 合計ジャッジ時間 | 19,884 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
n,m = map(int,input().split())
edgs = []
for i in range(m):
a,b = map(int,input().split())
edgs.append((a,b))
q = int(input())
query = []
use = {}
use_set = set()
for i in range(q):
a,b,c = map(int,input().split())
query.append((a,b,c))
use[b] = []
use_set.add(b)
if c != -1:
use[c] = []
use_set.add(c)
graph = {}
for i in use_set:
graph[i] = set()
for a,b in edgs:
if a in use_set and b in use_set:
graph[a].add(b)
p = {}
for i in use_set:
p[i] = True
syoki = n-len(use_set)
for a,b,c in query:
if a == 1:
if c in graph[b]:
graph[b].discard(c)
else:
graph[b].add(c)
else:
if p[b]:
p[b] = False
else:
p[b] = True
ans = syoki
for i in use_set:
if i in graph[b] or p[i] or i == b:
ans += 1
print(ans-1)
yt142857