結果
| 問題 | No.1779 Magical Swap | 
| コンテスト | |
| ユーザー |  沙耶花 | 
| 提出日時 | 2021-12-08 00:04:30 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 199 ms / 2,000 ms | 
| コード長 | 813 bytes | 
| コンパイル時間 | 4,063 ms | 
| コンパイル使用メモリ | 255,100 KB | 
| 最終ジャッジ日時 | 2025-01-26 06:39:10 | 
| ジャッジサーバーID (参考情報) | judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 18 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:28:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   28 |                         scanf("%d",&t);
      |                         ~~~~~^~~~~~~~~
main.cpp:33:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   33 |                         scanf("%d",&t);
      |                         ~~~~~^~~~~~~~~
            
            ソースコード
#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define Inf 1000000001
int main(){
	
	int _t;
	cin>>_t;
	
	rep(_,_t){
		int n;
		cin>>n;
		
		dsu D(n);
		for(int i=2;i<=n;i++){
			for(int j=i;j+i<=n;j+=i){
				D.merge(j-1,j+i-1);
			}
		}
		vector<vector<int>> a(n),b(n);
		rep(i,n){
			int t;
			scanf("%d",&t);
			a[D.leader(i)].push_back(t);
		}
		rep(i,n){
			int t;
			scanf("%d",&t);
			b[D.leader(i)].push_back(t);
		}
		bool f = true;
		rep(i,n){
			sort(a[i].begin(),a[i].end());
			sort(b[i].begin(),b[i].end());
			if(a[i]!=b[i]){
				f = false;
				//cout<<i<<','<<a[i].size()<<endl;
			}
		}
		if(f)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
			
	}
	
	return 0;
}
            
            
            
        