結果

問題 No.2319 Friends+
ユーザー no wayno way
提出日時 2023-05-26 22:18:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 551 ms / 3,000 ms
コード長 535 bytes
コンパイル時間 1,552 ms
コンパイル使用メモリ 165,996 KB
実行使用メモリ 101,640 KB
最終ジャッジ日時 2023-08-26 12:04:58
合計ジャッジ時間 20,710 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,476 KB
testcase_01 AC 2 ms
5,780 KB
testcase_02 AC 340 ms
54,260 KB
testcase_03 AC 300 ms
54,608 KB
testcase_04 AC 292 ms
54,660 KB
testcase_05 AC 281 ms
54,600 KB
testcase_06 AC 294 ms
54,592 KB
testcase_07 AC 503 ms
101,328 KB
testcase_08 AC 511 ms
101,304 KB
testcase_09 AC 505 ms
101,384 KB
testcase_10 AC 511 ms
101,336 KB
testcase_11 AC 551 ms
101,320 KB
testcase_12 AC 3 ms
8,364 KB
testcase_13 AC 3 ms
8,312 KB
testcase_14 AC 3 ms
8,232 KB
testcase_15 AC 3 ms
8,252 KB
testcase_16 AC 3 ms
8,312 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 366 ms
54,328 KB
testcase_19 AC 433 ms
101,316 KB
testcase_20 AC 361 ms
54,528 KB
testcase_21 AC 354 ms
54,528 KB
testcase_22 AC 360 ms
54,540 KB
testcase_23 AC 396 ms
78,872 KB
testcase_24 AC 374 ms
68,568 KB
testcase_25 AC 370 ms
62,488 KB
testcase_26 AC 362 ms
58,372 KB
testcase_27 AC 357 ms
55,916 KB
testcase_28 AC 358 ms
55,280 KB
testcase_29 AC 356 ms
54,684 KB
testcase_30 AC 357 ms
54,492 KB
testcase_31 AC 354 ms
54,520 KB
testcase_32 AC 382 ms
54,348 KB
testcase_33 AC 353 ms
54,352 KB
testcase_34 AC 355 ms
54,308 KB
testcase_35 AC 356 ms
54,528 KB
testcase_36 AC 415 ms
101,328 KB
testcase_37 AC 332 ms
54,600 KB
testcase_38 AC 376 ms
101,332 KB
testcase_39 AC 375 ms
101,308 KB
testcase_40 AC 369 ms
101,640 KB
testcase_41 AC 381 ms
101,396 KB
testcase_42 AC 382 ms
101,448 KB
testcase_43 AC 384 ms
101,380 KB
testcase_44 AC 376 ms
101,336 KB
testcase_45 AC 362 ms
101,336 KB
testcase_46 AC 335 ms
56,828 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
const int N=2e4+10;
bitset<N>a[2][N];
int p[N];
int n,m,x,y,q;
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++) {
		scanf("%d",&p[i]);
		a[0][p[i]][i]=1;
	}
	for (int i=1;i<=m;i++){
		scanf("%d%d",&x,&y);
		a[1][x][y]=1;
		a[1][y][x]=1;
	}
	scanf("%d",&q);
	for (int i=1;i<=q;i++){
		scanf("%d%d",&x,&y);
		if (p[x]!=p[y]){
			if ((a[0][p[y]]&a[1][x]).count()){
				puts("Yes");
				a[0][p[x]][x]=0;
				a[0][p[y]][x]=1;
				p[x]=p[y];
			}else puts("No");
		}else puts("No");
	}
}
0