-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2244C_Stepan_and_Permutation.cpp
More file actions
60 lines (60 loc) · 1.03 KB
/
Copy path2244C_Stepan_and_Permutation.cpp
File metadata and controls
60 lines (60 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Winners never Quit!
#include <bits/stdc++.h> // Problem -
using namespace std;
#define ll long long
#define pr pair<ll, ll>
#define pb push_back
#define fr(i, a, n) for (ll i = a; i < n; i++)
#define frr(i, a, n) for (ll i = n - 1; i >= a; i--)
#define elif else if
bool isprime(ll n)
{
if (n < 2) return false;
for (ll i = 2; i * i <= n; i++)
if (n % i == 0) return false;
return true;
}
ll pow(ll a, ll b) // O(log(b))
{
ll res = 1;
while (b)
{
if (b & 1) res *= a;
a *= a;
b >>= 1;
}
return res;
}
void solve()
{
ll n,x,y;
cin>>n>>x>>y;
vector<pair<ll,ll>> v(n);
fr(i,0,n) {
cin>>v[i].first;
v[i].second=i;
}
ranges::sort(v);
ll cnt=gcd(x,y);
fr(i,0,n){
if((v[i].second-i)%cnt){
cout<<"NO\n";
return;
}
}
cout<<"YES\n";
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
ll T; cin >> T;
while (T--)
solve();
return 0;
}