結果
問題 | No.1779 Magical Swap |
ユーザー | 沙耶花 |
提出日時 | 2021-12-08 00:04:30 |
言語 | C++17 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 189 ms / 2,000 ms |
コード長 | 813 bytes |
コンパイル時間 | 4,379 ms |
コンパイル使用メモリ | 264,008 KB |
実行使用メモリ | 9,572 KB |
最終ジャッジ日時 | 2023-09-23 07:46:46 |
合計ジャッジ時間 | 5,919 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,376 KB |
testcase_01 | AC | 2 ms
4,376 KB |
testcase_02 | AC | 9 ms
4,376 KB |
testcase_03 | AC | 3 ms
4,376 KB |
testcase_04 | AC | 45 ms
8,840 KB |
testcase_05 | AC | 20 ms
5,652 KB |
testcase_06 | AC | 23 ms
5,976 KB |
testcase_07 | AC | 40 ms
8,032 KB |
testcase_08 | AC | 2 ms
4,376 KB |
testcase_09 | AC | 13 ms
4,624 KB |
testcase_10 | AC | 49 ms
9,336 KB |
testcase_11 | AC | 26 ms
6,188 KB |
testcase_12 | AC | 9 ms
4,380 KB |
testcase_13 | AC | 38 ms
7,728 KB |
testcase_14 | AC | 47 ms
9,572 KB |
testcase_15 | AC | 189 ms
4,376 KB |
testcase_16 | AC | 47 ms
9,496 KB |
testcase_17 | AC | 41 ms
4,376 KB |
testcase_18 | AC | 1 ms
4,380 KB |
ソースコード
#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; }