結果

問題 No.2319 Friends+
ユーザー Carpenters-CatCarpenters-Cat
提出日時 2023-05-28 19:45:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 996 bytes
コンパイル時間 2,110 ms
コンパイル使用メモリ 211,220 KB
実行使用メモリ 325,248 KB
最終ジャッジ日時 2024-06-08 11:23:36
合計ジャッジ時間 32,322 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
10,752 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2,657 ms
27,904 KB
testcase_03 AC 2,462 ms
27,776 KB
testcase_04 AC 2,215 ms
27,776 KB
testcase_05 AC 2,323 ms
27,776 KB
testcase_06 AC 2,473 ms
27,776 KB
testcase_07 AC 811 ms
34,560 KB
testcase_08 AC 765 ms
34,688 KB
testcase_09 AC 753 ms
34,560 KB
testcase_10 AC 740 ms
34,560 KB
testcase_11 AC 839 ms
34,560 KB
testcase_12 AC 4 ms
5,376 KB
testcase_13 AC 3 ms
5,376 KB
testcase_14 AC 3 ms
5,376 KB
testcase_15 AC 3 ms
5,376 KB
testcase_16 AC 4 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 442 ms
11,520 KB
testcase_19 AC 550 ms
25,216 KB
testcase_20 AC 818 ms
22,528 KB
testcase_21 AC 625 ms
19,840 KB
testcase_22 AC 1,063 ms
24,064 KB
testcase_23 AC 655 ms
25,344 KB
testcase_24 AC 560 ms
25,344 KB
testcase_25 TLE -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main () {
	int N, M;
	cin >> N >> M;
	std::vector<int> A(N);
	for (auto& a : A) cin >> a;
	vector<vector<int>> gr(N);
	for (int i = 0; i < M; i ++) {
		int a, b;
		cin >> a >> b;
		gr[--a].push_back(--b);
		gr[b].push_back(a);
	}
	int s = 4500;
	vector<vector<int>> bb(N);
	vector<unordered_map<int, int>> X(N);
	for (int i = 0; i < N; i ++) {
		if (gr[i].size() > s) {
			for (auto v : gr[i]) {
				bb[v].push_back(i);
			}
		} else {
			for (auto v : gr[i]) {
				X[v][A[i]] ++;
			}
		}
	}
	int Q;
	cin >> Q;
	while (Q--) {
		int x, y;
		cin >> x >> y;
		x --; y --;
		if (A[x] == A[y]) {
			puts("No");
			continue;
		}
		int a = A[y];
		bool ok = false;
		if (X[x][a] > 0) {
			ok = true;
		} else {
			for (auto v : bb[x]) {
				ok = ok || (a == A[v]);
			}
		}
		if (ok) {
			puts("Yes");
			if (gr[x].size() <= s) {
				for (auto v : gr[x]) {
					X[v][A[x]] --;
					X[v][a] ++;
				}
			}
			A[x] = a;
		} else {
			puts("No");
		}
	}
}
0