結果

問題 No.2346 Replace!!
ユーザー kotatsugamekotatsugame
提出日時 2023-06-09 23:55:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 497 bytes
コンパイル時間 553 ms
コンパイル使用メモリ 66,840 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-30 15:01:57
合計ジャッジ時間 4,564 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 3 ms
4,384 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 3 ms
4,380 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 4 ms
4,380 KB
testcase_32 AC 3 ms
4,380 KB
testcase_33 AC 3 ms
4,380 KB
testcase_34 AC 4 ms
4,376 KB
testcase_35 AC 4 ms
4,376 KB
testcase_36 AC 3 ms
4,376 KB
testcase_37 AC 3 ms
4,376 KB
testcase_38 AC 3 ms
4,380 KB
testcase_39 AC 4 ms
4,384 KB
testcase_40 AC 4 ms
4,380 KB
testcase_41 AC 4 ms
4,376 KB
testcase_42 WA -
testcase_43 AC 4 ms
4,380 KB
testcase_44 AC 5 ms
4,380 KB
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 AC 50 ms
4,380 KB
testcase_55 AC 50 ms
4,380 KB
testcase_56 AC 50 ms
4,376 KB
testcase_57 AC 50 ms
4,376 KB
testcase_58 AC 51 ms
4,380 KB
testcase_59 AC 51 ms
4,380 KB
testcase_60 AC 50 ms
4,380 KB
testcase_61 AC 50 ms
4,380 KB
testcase_62 AC 51 ms
4,380 KB
testcase_63 AC 51 ms
4,376 KB
testcase_64 AC 50 ms
4,380 KB
testcase_65 AC 50 ms
4,380 KB
testcase_66 WA -
testcase_67 AC 51 ms
4,384 KB
testcase_68 AC 51 ms
4,380 KB
testcase_69 WA -
testcase_70 WA -
testcase_71 WA -
testcase_72 WA -
testcase_73 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
using namespace std;
int N,A[5000],B[5000];
bool vis[5000];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int T;
	cin>>T;
	for(;T--;)
	{
		cin>>N;
		for(int i=0;i<N;i++)cin>>A[i],A[i]--;
		for(int i=0;i<N;i++)cin>>B[i],B[i]--;
		bool ok=true;
		for(int i=0;i<N;i++)
		{
			int u=A[i];
			for(int j=0;j<N;j++)vis[j]=false;
			while(!vis[u])
			{
				vis[u]=true;
				u=A[u];
			}
			if(!vis[B[i]])ok=false;
		}
		cout<<(ok?"Yes\n":"No\n");
	}
}
0