Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define _test int _TEST; cin>>_TEST; while(_TEST--)
- #define pb push_back
- #define ppb pop_back
- #define pf push_front
- #define ppf pop_front
- int main()
- {
- _test
- {
- int n, c, d;
- cin>>n>>c>>d;
- vector<int> a(n*n);
- for(auto &e: a)
- cin>>e;
- int x = *min_element(a.begin(), a.end());
- vector<vector<int>> tmp(n, vector<int> (n));
- tmp[0][0] = x;
- for(int j=0; j<n-1; j++)
- tmp[0][j+1] = tmp[0][j] + d;
- for(int i=0; i<n-1; i++)
- {
- for(int j=0; j<n; j++)
- tmp[i+1][j] = tmp[i][j] + c;
- }
- vector<int> b;
- for(int i=0; i<n; i++)
- {
- for(int j=0; j<n; j++)
- b.pb(tmp[i][j]);
- }
- sort(a.begin(), a.end());
- sort(b.begin(), b.end());
- if(a == b) cout<<"YES\n";
- else cout<<"NO\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement