結果
| 問題 |
No.2319 Friends+
|
| コンテスト | |
| ユーザー |
hitonanode
|
| 提出日時 | 2023-05-27 23:18:55 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 475 ms / 3,000 ms |
| コード長 | 1,002 bytes |
| コンパイル時間 | 1,681 ms |
| コンパイル使用メモリ | 96,040 KB |
| 実行使用メモリ | 101,120 KB |
| 最終ジャッジ日時 | 2024-12-26 05:33:14 |
| 合計ジャッジ時間 | 17,296 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 45 |
ソースコード
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <bitset>
#include <iostream>
#include <vector>
using namespace std;
int main() {
cin.tie(nullptr), ios::sync_with_stdio(false);
int N, M;
cin >> N >> M;
using BS = bitset<20000>;
vector<BS> is_friend(N), world_has(N);
vector<int> P(N);
for (int i = 0; i < N; ++i) cin >> P.at(i), P.at(i)--, world_has.at(P.at(i)).set(i);
while (M--) {
int a, b;
cin >> a >> b;
--a, --b;
is_friend.at(a).set(b);
is_friend.at(b).set(a);
}
int Q;
cin >> Q;
while (Q--) {
int x, y;
cin >> x >> y;
--x, --y;
int j = P.at(y);
if (P.at(x) != P.at(y) and (world_has.at(P.at(y)) & is_friend.at(x)).any()) {
puts("Yes");
world_has.at(P.at(x)).reset(x);
P.at(x) = P.at(y);
world_has.at(P.at(x)).set(x);
} else {
puts("No");
}
}
}
hitonanode