# |
Author |
Problem |
Lang |
Verdict |
Time |
Memory |
Sent |
Judged |
|
166799175 |
Practice:
r0hit |
1714E
- 25
|
GNU C++14
|
Wrong answer on test 2
|
15 ms
|
144 KB
|
2022-08-03 14:24:04 |
2022-08-03 14:24:04 |
|
#include <bits/stdc++.h>
using namespace std;
#define INF 1e18
#define MOD 1000000007
// #define N 300015
#define N 15
typedef long long int ll;
typedef long double lld;
typedef unsigned long long ull;
#ifndef ONLINE_JUDGE
#define debug(x) \
cerr << #x << " "; \
_print(x); \
cerr << endl;
#else
#define debug(x)
#endif
void _print(ll t)
{
cerr << t;
}
void _print(int t) { cerr << t; }
void _print(string t) { cerr << t; }
void _print(char t) { cerr << t; }
void _print(lld t) { cerr << t; }
void _print(double t) { cerr << t; }
void _print(ull t) { cerr << t; }
template <class T, class V>
void _print(pair<T, V> p);
template <class T>
void _print(vector<T> v);
template <class T>
void _print(set<T> v);
template <class T, class V>
void _print(map<T, V> v);
template <class T>
void _print(multiset<T> v);
template <class T, class V>
void _print(pair<T, V> p)
{
cerr << "{";
_print(p.first);
cerr << ",";
_print(p.second);
cerr << "}";
}
template <class T>
void _print(vector<T> v)
{
cerr << "[ ";
for (T i : v)
{
_print(i);
cerr << " ";
}
cerr << "]";
}
template <class T>
void _print(set<T> v)
{
cerr << "[ ";
for (T i : v)
{
_print(i);
cerr << " ";
}
cerr << "]";
}
template <class T>
void _print(multiset<T> v)
{
cerr << "[ ";
for (T i : v)
{
_print(i);
cerr << " ";
}
cerr << "]";
}
template <class T, class V>
void _print(map<T, V> v)
{
cerr << "[ ";
for (auto i : v)
{
_print(i);
cerr << " ";
}
cerr << "]";
}
ll _lu[N][(int)log2(N)];
void preprocess(vector<ll> a, bool _isSum = false)
{
int n = a.size();
ll lg = log2(n);
for (int i = 0; i < n; i++)
{
_lu[i][0] = a[i];
}
for (int j = 1; j <= lg; j++)
{
for (int i = 0; i + (1 << j) - 1 < n; i++)
{
if (_isSum)
_lu[i][j] = _lu[i][j - 1] + _lu[i + (1 << (j - 1))][j - 1];
else
_lu[i][j] = max(_lu[i][j - 1], _lu[i + (1 << (j - 1))][j - 1]);
}
}
}
ll query(ll l, ll r, bool _isSum = false)
{
if(l > r)
swap(l, r);
ll ans;
if (_isSum)
{
ans = 0;
ll k = r - l + 1, j = log2(k);
for (int i = 0; i <= j; i++)
if (k & (1 << i))
{
ans += _lu[l][i];
l += (1 << i);
}
}
else
{
ll j = log2(r - l + 1);
ans = max(_lu[l][j], _lu[r - (1 << j) + 1][j]);
}
return ans;
}
typedef vector<ll> vll;
typedef vector<double> vdd;
typedef pair<ll, ll> pll;
vll gr[N], child(N, 0), edge(N, 0);
vll parent, Rank;
ll Find(int i)
{
if(parent[i] == i)
return i;
return parent[i] = Find(parent[i]);
}
void Union(ll i, ll j)
{
i = Find(i);
j = Find(j);
if(Rank[i] > Rank[j])
{
Rank[i]++;
parent[j] = i;
}
else
{
Rank[j]++;
parent[i] = j;
}
}
vector <bool> vis;
vll col;
map <ll, vll> mp;
int flag = 0;
void dfs(int node, int parent = -1, int c = 0)
{
debug(node);
bool ans = true;
vis[node] = 1;
col[node] = c;
for(auto i: mp[node])
{
debug(i)
if(vis[i] && col[i] == c)
{
flag = 1;
break;
}
if(!vis[i])
dfs(i, node, !c);
}
}
bool isOverlap(ll &left, ll &right, ll l, ll r)
{
if((left >= l && left <= r) || (right >= l && right <= r))
{
left = max(left, l);
right = min(right, r);
return true;
}
left = l;
right = r;
return false;
}
void solve()
{
ll tt;
cin >> tt;
// tt = 1;
for (ll pp = 0; pp < tt; pp++)
{
ll n;
cin >> n;
vll a(n);
for (int i = 0; i < n; i++)
{
cin >> a[i];
}
sort(a.begin(), a.end());
if(a[n - 1] % 10 == 5)
{
a[n - 1] += 5;
}
else if(a[n - 1] % 10 != 0)
{
while(true)
{
a[n - 1] += (a[n - 1] % 10);
if(a[n - 1] % 10 == 8)
break;
}
}
int flag = 0;
ll cmp = a[n - 1] / 10;
for (int i = 0; i < n - 1; i++)
{
if(a[i] != a[n - 1])
{
ll temp = a[i] / 10, rem = a[i] % 10, diff = cmp - temp;
switch(rem)
{
case 0: flag = 1;
break;
case 1: if(diff % 2)
flag = 1;
break;
case 2: if(diff % 2)
flag = 1;
break;
case 3: if(diff % 2 == 0)
flag = 1;
break;
case 4: if(diff % 2)
flag = 1;
break;
case 5: if(a[i] + 5 != a[n - 1])
flag = 1;
break;
case 6: if(diff % 2 == 0)
flag = 1;
break;
case 7: if(diff % 2 == 0)
flag = 1;
break;
case 8: if(diff % 2)
flag = 1;
break;
case 9: if(diff % 2 == 0)
flag = 1;
break;
}
}
if(flag)
break;
}
if(flag)
cout << "NO\n";
else
cout << "YES\n";
}
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("input", "r", stdin);
freopen("output", "w", stdout);
freopen("error", "w", stderr);
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);
solve();
return 0;
}
Click to see test details