QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#573480 | #3940. ISP Merger | LaVuna47# | AC ✓ | 38ms | 13072kb | C++17 | 4.2kb | 2024-09-18 18:57:31 | 2024-09-18 18:57:42 |
Judging History
answer
/** gnu specific **/
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
/** contains everything I need in std **/
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(S) ((int)S.size())
#define FOR(i, n) for(int i = 0; i < n; ++i)
#define RFOR(i, n) for(int i = n-1; i >= 0; --i)
#define output_vec(vec) { FOR(i_, sz(vec)) cout << vec[i_] << ' '; cout << '\n'; }
#define x first
#define y second
#define pb push_back
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<bool> vb;
typedef short si;
typedef unsigned long long ull;
typedef long double LD;
typedef pair<ull, ull> pull;
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
using namespace std;
#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif
vector<vector<int>> g;
vector<bool> vis;
void dfs(int v, vector<int>& comp)
{
vis[v] = 1;
comp.pb(v);
for (int to: g[v])
if (!vis[to])
dfs(to, comp);
}
int solve()
{
int n, m, k;
if (!(cin >> n >> m >> k))
return 1;
g.clear();
g.resize(n);
vis.clear();
vis.resize(n, false);
vector<int> cap(n);
FOR (i, n)
cin >> cap[i];
FOR (i, m)
{
int v, w;
cin >> v >> w;
g[v].pb(w);
g[w].pb(v);
}
if (n == 1)
{
cout << "yes\n";
return 0;
}
vector<vector<int>> comps;
vector<int> comp;
FOR (i, n)
{
if (!vis[i])
dfs(i, comp);
if (!comp.empty())
comps.pb(comp);
comp.clear();
}
int nn = sz(comps);
//cout << "nn = " << nn << '\n';
if (nn == 1)
{
cout << "yes\n";
return 0;
}
// 1 < nn -k
if (nn - k > 1)
{
cout << "no\n";
return 0;
}
vector<int> caps(nn), as(nn);
FOR (i, nn)
{
int curr = 0;
auto el = comps[i];
for (int idx: el)
curr += -sz(g[idx]) + cap[idx];
caps[i] = curr;
curr = 0;
for (int idx: el)
curr += sz(g[idx]);
curr /= 2;
//cout << "curr = " << curr << '\n';
as[i] = curr - (sz(comps[i]) - 1);
}
//FOR (i, nn)
//cout << caps[i] << ' ';
//cout << '\n';
vector<int> newcaps, newas;
FOR (i, nn)
{
if (caps[i])
{
newcaps.pb(caps[i]);
newas.pb(as[i]);
}
else if (as[i])
{
newcaps.pb(caps[i] + 2);
newas.pb(as[i] - 1);
--k;
}
else
{
newcaps.pb(1);
newcaps.pb(1);
newas.pb(0);
newas.pb(0);
--k;
}
}
caps.swap(newcaps);
as.swap(newas);
nn = sz(caps);
int sma = accumulate(all(as), 0);
int smcaps = accumulate(all(caps), 0);
//FOR (i, nn)
//cout << caps[i] << ' ';
//cout << '\n';
k -= nn - 1;
if (k < 0)
{
cout << "no\n";
return 0;
}
while (sma > 0 && smcaps < 2 * (nn - 1))
{
sma--;
smcaps += 2;
--k;
if (k < 0)
{
cout << "no\n";
return 0;
}
}
if (smcaps >= 2 * (nn - 1))
cout << "yes\n";
else
cout << "no\n";
return 0;
}
int32_t main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int TET = 1e9;
//cin >> TET;
for (int i = 1; i <= TET; i++)
{
if (solve())
{
break;
}
#ifdef ONPC
cout << "__________________________" << endl;
#endif
}
#ifdef ONPC
cerr << endl << "finished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec" << endl;
#endif
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3716kb
input:
4 5 2 3 3 3 3 0 1 0 3 1 3 1 2 2 3
output:
yes
result:
ok answer is YES
Test #2:
score: 0
Accepted
time: 0ms
memory: 3888kb
input:
5 4 4 1 1 2 2 2 0 1 2 3 3 4 4 2
output:
yes
result:
ok answer is YES
Test #3:
score: 0
Accepted
time: 0ms
memory: 3844kb
input:
3 0 3 1 1 1
output:
no
result:
ok answer is NO
Test #4:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
500 500 165 2 2 2 1 2 3 3 2 2 3 3 3 3 2 3 4 2 1 1 2 5 1 1 1 3 1 1 1 1 1 1 1 2 1 1 1 4 2 2 3 1 3 2 2 1 2 4 1 1 1 1 5 2 2 1 4 1 2 5 1 3 2 1 2 5 1 2 1 2 3 2 1 2 1 1 2 1 1 1 1 2 4 2 1 3 3 4 3 3 1 3 2 1 1 1 2 2 2 1 1 1 2 5 1 3 5 3 2 2 2 2 2 4 1 2 3 2 2 2 2 2 1 2 2 3 2 2 2 4 4 5 1 4 1 1 1 4 4 1 2 1 2 2 2 ...
output:
yes
result:
ok answer is YES
Test #5:
score: 0
Accepted
time: 0ms
memory: 3696kb
input:
504 502 159 2 1 3 1 3 2 1 1 2 3 3 1 7 1 3 2 2 2 4 1 2 1 2 3 1 1 1 3 1 2 3 2 1 1 2 1 1 4 1 4 1 3 1 2 3 2 2 2 3 3 1 3 2 4 2 1 1 2 1 2 1 1 3 1 1 5 1 2 2 4 1 3 3 2 1 1 1 3 1 2 3 2 3 1 1 3 3 1 5 1 5 1 2 2 2 1 2 2 2 1 1 1 1 1 3 1 2 3 3 1 3 1 1 1 1 2 3 1 6 3 2 2 1 1 1 1 3 3 4 3 3 2 4 1 1 1 2 4 1 3 2 1 3 1 ...
output:
yes
result:
ok answer is YES
Test #6:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
504 503 154 1 1 2 3 1 1 2 1 1 1 4 2 1 2 3 2 3 2 6 1 1 4 3 5 1 3 1 3 1 1 2 3 2 1 2 4 2 1 1 4 2 1 1 2 1 2 1 2 1 4 1 3 3 2 3 3 1 4 3 1 2 5 3 5 3 3 3 1 2 3 2 1 1 2 1 1 2 4 1 3 1 1 1 2 1 1 2 3 1 1 2 4 3 3 2 4 1 3 1 1 1 4 2 1 1 1 1 1 1 1 1 5 1 3 2 1 1 1 3 1 4 2 5 2 1 2 1 2 3 2 2 1 4 1 2 4 4 4 8 1 2 1 3 1 ...
output:
no
result:
ok answer is NO
Test #7:
score: 0
Accepted
time: 0ms
memory: 3888kb
input:
502 301 245 1 2 2 1 2 1 2 2 1 3 2 1 1 3 3 1 2 1 3 3 2 2 4 1 2 1 1 2 1 1 3 4 1 2 5 2 1 1 3 4 2 4 3 2 1 2 2 2 1 2 1 1 1 2 2 1 1 1 2 4 1 1 3 1 1 1 2 2 1 1 1 1 2 1 1 1 4 1 3 3 3 2 2 3 2 2 4 2 4 1 4 2 1 1 3 1 2 1 1 2 2 2 1 3 1 2 3 1 2 1 3 1 1 5 1 1 1 3 3 2 2 2 2 1 1 2 1 3 3 1 2 3 3 2 2 1 1 2 2 1 1 2 2 3 ...
output:
no
result:
ok answer is NO
Test #8:
score: 0
Accepted
time: 2ms
memory: 4120kb
input:
5194 7192 555 5 2 3 3 2 3 4 4 3 1 4 2 5 2 1 3 5 1 2 3 1 3 1 2 4 2 3 2 3 6 3 3 1 1 5 2 1 1 4 1 1 4 2 4 1 3 3 2 3 6 1 3 4 1 5 2 2 3 2 1 6 3 3 2 2 3 1 2 2 1 1 1 5 4 2 2 5 1 1 3 2 1 3 3 2 3 2 3 2 1 2 3 2 3 3 4 1 6 4 3 7 5 6 4 6 2 3 2 2 1 1 2 2 4 4 4 2 5 5 3 1 2 6 3 7 2 2 1 1 4 2 3 3 2 4 2 3 1 6 7 5 4 3 ...
output:
yes
result:
ok answer is YES
Test #9:
score: 0
Accepted
time: 2ms
memory: 4172kb
input:
5246 7245 497 5 3 1 4 3 2 2 5 4 2 3 2 7 2 2 3 5 2 1 2 1 5 1 2 5 2 3 3 4 4 3 4 3 2 2 2 2 1 3 5 1 2 1 4 2 4 3 4 4 3 2 2 1 6 3 1 2 5 5 3 1 4 1 3 2 1 4 3 5 3 6 2 1 4 3 5 5 2 1 5 2 3 1 1 1 3 4 4 4 3 5 4 5 3 2 3 5 5 1 4 5 2 7 7 2 6 1 4 5 3 2 1 6 3 2 5 6 2 1 3 5 4 2 5 1 2 1 1 3 3 3 2 2 1 1 4 3 1 4 4 7 1 4 ...
output:
yes
result:
ok answer is YES
Test #10:
score: 0
Accepted
time: 2ms
memory: 4400kb
input:
5060 7059 551 1 5 3 3 3 2 1 5 2 2 2 2 2 3 5 5 1 3 2 3 4 4 4 5 1 2 1 1 2 6 4 3 7 2 2 4 2 2 6 5 8 2 4 1 1 4 1 3 4 3 4 4 5 1 2 2 3 3 1 4 2 2 3 1 2 1 1 2 2 3 1 5 3 1 3 1 5 5 3 1 4 2 2 2 1 4 1 6 3 1 2 2 1 5 5 2 4 3 3 1 3 2 5 5 2 2 2 6 2 4 3 8 2 3 1 3 4 1 1 1 1 2 4 4 5 5 8 2 3 6 3 4 1 2 1 3 3 3 1 1 1 1 1 ...
output:
no
result:
ok answer is NO
Test #11:
score: 0
Accepted
time: 1ms
memory: 4100kb
input:
5050 3048 2279 1 5 1 2 1 1 2 1 5 3 1 1 4 3 2 4 2 1 2 4 3 2 3 1 2 1 1 1 1 2 1 4 3 2 2 3 1 3 2 1 3 2 1 3 1 2 1 3 1 3 4 3 2 1 2 2 3 2 2 2 3 1 2 1 1 1 1 1 1 3 1 1 3 1 2 1 2 1 1 1 2 2 1 1 2 2 2 2 4 2 4 2 4 2 3 1 4 2 1 2 1 2 4 2 4 2 4 2 3 1 3 2 1 1 2 1 5 2 2 1 3 3 2 2 5 4 1 1 2 1 1 1 1 1 2 2 2 1 2 1 3 2 2...
output:
no
result:
ok answer is NO
Test #12:
score: 0
Accepted
time: 9ms
memory: 5972kb
input:
25457 35456 2670 3 8 1 2 2 3 4 1 2 1 4 1 3 1 2 1 4 3 5 2 8 4 2 3 1 2 3 3 2 2 2 1 2 1 2 2 1 3 2 1 4 4 3 6 1 2 4 1 2 2 3 3 3 6 5 4 4 2 4 2 5 3 4 1 3 1 1 3 5 1 1 2 2 4 2 1 3 4 2 2 6 2 3 1 2 1 4 4 4 5 1 4 1 5 4 3 2 3 10 3 5 1 4 2 4 4 1 6 4 1 3 1 3 5 3 3 6 2 1 2 2 5 1 1 4 4 4 2 2 6 1 2 2 4 2 1 4 3 1 4 3 ...
output:
yes
result:
ok answer is YES
Test #13:
score: 0
Accepted
time: 5ms
memory: 5572kb
input:
25585 15584 11514 3 2 1 1 3 1 1 2 1 1 2 1 1 2 2 3 2 1 4 1 2 1 1 1 3 2 3 1 2 1 3 1 2 1 1 2 4 4 2 2 3 3 4 2 1 2 2 1 1 1 3 4 1 1 4 5 2 1 3 3 1 1 3 2 2 3 1 1 1 1 2 2 1 3 2 4 2 2 2 3 1 1 2 1 2 2 1 1 1 2 1 1 3 2 1 4 1 1 2 1 1 6 3 2 4 2 1 3 3 2 2 1 2 3 4 2 2 1 2 3 1 2 2 1 1 2 1 4 1 3 1 3 3 3 2 1 3 2 2 2 3 ...
output:
no
result:
ok answer is NO
Test #14:
score: 0
Accepted
time: 9ms
memory: 6092kb
input:
25247 35246 2758 5 2 3 3 3 2 2 1 1 2 3 3 4 2 3 4 2 2 5 3 1 2 4 1 2 1 1 1 4 2 3 3 7 2 8 3 1 4 1 5 1 1 2 1 3 3 3 3 1 2 8 1 1 3 1 3 3 2 2 4 1 7 1 3 1 2 4 3 1 3 6 2 3 4 5 3 2 2 3 3 3 3 1 1 2 3 4 5 2 1 2 2 1 1 3 3 7 4 2 2 3 3 3 1 5 2 2 3 4 3 2 5 3 1 7 3 5 1 5 4 1 2 3 1 3 1 3 4 3 4 4 4 3 3 3 1 1 2 4 2 1 3...
output:
no
result:
ok answer is NO
Test #15:
score: 0
Accepted
time: 5ms
memory: 5408kb
input:
25296 15294 11375 3 3 1 1 1 1 3 1 5 2 2 1 1 5 3 2 4 3 1 2 3 2 2 4 1 2 1 2 3 2 5 2 1 1 3 2 4 2 3 2 3 2 3 3 2 1 1 5 1 1 1 6 2 1 2 1 2 1 1 1 1 2 2 1 4 5 1 2 2 3 1 1 2 2 1 3 1 1 2 1 1 3 1 2 1 2 3 2 1 2 1 1 3 1 2 2 1 2 3 1 1 6 1 2 1 1 1 1 2 1 1 1 1 1 4 4 1 1 4 2 3 3 3 3 3 3 3 3 1 2 5 2 1 3 3 2 1 1 4 6 2 ...
output:
no
result:
ok answer is NO
Test #16:
score: 0
Accepted
time: 7ms
memory: 5960kb
input:
25748 35746 2794 1 1 3 3 4 4 2 2 3 5 3 2 3 2 8 2 1 4 3 6 2 2 2 4 4 4 3 3 5 5 1 3 2 2 2 1 2 3 3 4 3 3 4 1 3 2 3 3 2 3 5 4 4 4 2 3 2 2 3 1 1 1 4 3 2 5 2 1 6 4 2 1 2 1 1 4 2 3 3 2 3 5 2 2 3 3 2 2 3 4 6 6 4 3 2 3 1 3 3 1 5 2 2 5 1 2 2 2 2 2 3 1 3 6 3 4 1 5 3 2 2 3 1 4 6 7 2 2 1 1 1 5 4 1 5 3 3 1 1 1 5 6...
output:
yes
result:
ok answer is YES
Test #17:
score: 0
Accepted
time: 2ms
memory: 5416kb
input:
25118 15117 11432 1 1 2 4 2 1 2 4 1 3 1 3 1 1 2 2 1 2 1 2 1 2 1 3 1 2 1 2 1 1 4 2 3 3 1 1 3 2 1 2 3 4 2 2 1 2 1 2 3 1 1 1 1 1 1 1 2 1 5 1 4 3 2 1 4 1 3 3 1 1 3 1 1 2 2 1 2 2 1 1 1 1 1 2 1 3 2 2 3 4 1 2 3 1 2 3 1 1 2 3 4 1 1 2 2 2 2 1 1 2 1 2 2 2 2 3 1 2 2 1 2 1 2 1 1 3 3 3 1 1 1 1 2 1 1 1 2 1 3 2 2 ...
output:
no
result:
ok answer is NO
Test #18:
score: 0
Accepted
time: 9ms
memory: 5864kb
input:
25142 35141 2743 6 3 3 3 2 2 2 4 3 1 5 2 5 2 3 1 2 2 1 2 1 1 3 2 2 4 2 4 4 4 1 1 2 2 3 1 3 4 2 2 2 1 2 4 1 6 3 3 2 1 1 1 1 3 3 2 2 2 1 1 4 5 1 3 1 5 1 1 1 5 1 4 2 4 4 1 4 5 3 3 2 1 3 2 3 1 5 1 6 4 3 8 6 3 5 1 4 5 1 5 4 1 4 3 2 2 3 2 7 6 4 5 5 1 4 2 1 1 4 4 1 1 4 4 1 4 1 1 5 1 3 3 3 4 2 1 1 4 7 4 3 4...
output:
no
result:
ok answer is NO
Test #19:
score: 0
Accepted
time: 3ms
memory: 5524kb
input:
25332 15331 11383 2 4 1 2 3 3 2 2 2 1 1 2 3 3 2 2 1 1 3 2 3 3 2 1 1 1 2 1 1 1 3 1 1 3 2 2 1 2 1 1 2 4 1 1 1 2 2 1 1 2 4 1 1 2 5 2 4 3 3 1 1 3 1 2 1 1 2 1 2 2 1 1 2 5 2 1 1 2 1 2 1 4 3 1 2 1 1 1 2 1 1 2 4 2 1 1 3 1 2 1 2 2 1 1 3 2 1 2 2 3 2 1 2 2 1 3 4 5 1 3 1 2 2 1 2 4 1 3 4 1 2 1 2 1 3 3 4 2 2 3 1 ...
output:
no
result:
ok answer is NO
Test #20:
score: 0
Accepted
time: 36ms
memory: 12932kb
input:
90178 150177 5244 1 4 1 2 2 3 2 5 1 5 1 1 4 4 1 5 1 4 7 1 1 2 3 5 5 1 2 4 1 4 5 1 9 3 5 3 3 3 5 1 4 4 2 2 5 3 4 2 5 1 4 3 4 10 5 3 5 3 3 6 2 5 6 2 5 1 2 1 4 1 4 5 1 3 2 6 4 2 3 1 4 3 5 4 4 4 2 2 2 2 3 3 3 1 7 3 6 3 3 2 6 1 7 8 4 1 5 2 5 4 1 2 4 4 2 2 2 2 4 5 6 5 1 1 3 6 3 3 5 5 5 4 3 3 5 2 4 8 3 1 4...
output:
yes
result:
ok answer is YES
Test #21:
score: 0
Accepted
time: 17ms
memory: 11092kb
input:
91153 51152 44264 2 2 1 3 4 2 1 1 1 1 3 3 6 3 3 1 3 1 1 3 4 4 2 3 2 1 1 2 1 1 3 1 1 1 1 3 3 4 3 1 2 1 1 2 1 3 2 2 1 1 2 1 1 2 1 1 2 1 1 4 2 3 2 2 2 3 2 1 3 3 5 2 2 4 1 1 2 2 4 2 2 4 2 1 1 3 1 2 2 2 3 4 4 2 4 1 2 3 1 4 1 1 2 1 1 3 2 1 2 3 2 1 1 2 3 2 3 1 1 1 2 2 3 2 2 1 3 3 2 2 3 3 2 2 2 3 3 3 1 1 1 ...
output:
no
result:
ok answer is NO
Test #22:
score: 0
Accepted
time: 38ms
memory: 13072kb
input:
90943 150942 5147 4 1 4 2 3 5 7 5 2 4 1 8 3 5 1 4 2 5 3 4 1 6 6 1 5 4 3 4 3 3 5 1 4 3 2 3 3 2 6 4 4 3 5 7 2 3 1 2 3 5 5 5 1 4 6 3 5 3 6 8 7 4 2 2 5 1 3 4 3 3 2 4 2 2 1 3 5 3 5 1 5 6 4 2 2 4 3 6 11 4 4 5 3 2 3 3 5 7 3 1 1 2 3 4 2 7 3 5 6 4 2 1 6 4 1 3 1 2 4 6 1 2 2 3 6 6 3 4 8 3 2 3 5 5 6 7 4 3 3 2 4...
output:
no
result:
ok answer is NO
Test #23:
score: 0
Accepted
time: 17ms
memory: 11148kb
input:
92543 52539 44509 1 1 1 1 1 1 1 1 2 2 2 1 2 3 2 2 3 1 2 1 3 2 1 4 1 1 1 3 1 1 3 1 1 3 1 1 1 3 4 1 1 1 2 2 1 2 4 2 1 3 2 1 2 3 3 5 1 1 1 1 2 2 1 1 3 2 1 1 4 1 4 3 1 4 1 1 2 1 2 1 1 1 1 4 2 3 1 1 3 2 2 1 2 3 1 1 1 3 2 4 4 1 1 2 1 1 1 2 5 2 1 2 2 1 3 1 2 3 2 1 3 1 1 3 1 1 1 3 1 3 3 1 2 2 2 3 1 2 1 3 2 ...
output:
no
result:
ok answer is NO
Test #24:
score: 0
Accepted
time: 29ms
memory: 9832kb
input:
69428 159427 8 13 20 26 27 11 12 19 25 23 21 18 21 28 18 23 26 19 21 14 13 24 22 23 18 18 20 13 23 18 29 25 30 15 18 22 19 21 24 12 20 19 17 22 22 19 23 24 14 19 22 19 11 27 23 16 16 23 24 20 15 18 25 23 18 13 30 24 19 20 30 13 20 19 19 24 21 17 16 22 17 23 19 18 21 28 20 19 20 23 22 21 24 16 22 16 ...
output:
yes
result:
ok answer is YES
Test #25:
score: 0
Accepted
time: 23ms
memory: 9624kb
input:
91088 81086 10010 4 1 2 1 3 1 1 1 5 3 2 3 1 1 2 1 3 2 3 2 6 2 4 3 3 2 3 2 2 2 3 1 1 2 1 1 1 2 1 3 4 1 4 1 2 2 2 3 2 2 3 1 1 2 2 2 1 2 1 1 1 2 3 5 1 3 2 1 2 4 1 3 1 1 1 2 2 1 1 2 1 1 2 2 4 1 1 2 1 1 5 3 1 1 1 1 2 1 1 2 1 2 2 1 2 3 1 2 2 3 4 1 2 5 1 1 2 1 1 1 1 4 2 2 2 1 1 1 1 2 2 3 1 2 2 1 2 2 2 2 2 ...
output:
no
result:
ok answer is NO
Test #26:
score: 0
Accepted
time: 35ms
memory: 10188kb
input:
75683 165682 7 26 31 19 20 17 18 13 20 23 27 22 23 14 14 32 11 19 25 20 23 14 12 20 20 19 16 22 20 19 16 28 14 17 23 16 23 14 22 20 28 18 21 21 27 24 16 25 21 18 17 19 20 28 23 19 19 17 24 18 19 15 22 15 19 25 14 21 25 11 19 24 22 28 19 15 21 18 21 23 18 16 20 20 18 20 21 19 11 26 16 19 26 19 24 16 ...
output:
no
result:
ok answer is NO
Test #27:
score: 0
Accepted
time: 15ms
memory: 7732kb
input:
60863 50862 10007 2 1 2 2 2 1 5 2 1 1 3 2 1 1 2 1 2 1 2 3 2 4 1 2 1 2 3 2 1 2 3 2 1 2 3 2 2 3 1 3 2 2 1 2 3 2 3 2 4 2 2 3 2 1 4 2 2 1 3 3 1 2 1 2 1 2 1 1 1 2 1 1 3 1 2 1 4 1 2 2 3 2 2 1 2 1 2 1 1 2 1 1 1 1 1 2 2 1 3 1 2 2 3 1 2 3 1 2 1 1 3 2 1 3 2 2 1 1 3 1 2 2 2 1 3 1 2 3 3 3 2 1 2 1 3 3 3 1 2 5 2 ...
output:
no
result:
ok answer is NO