# Getting WA , help plz!

This is mine code …
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

void solve(ll *t, ll n)
{
ll ok = true;
for (ll i = 0; i < n && ok; i++)
ok = t[i] ^ t[i + 1];
if (ok)
{
if (n & 1)
{
cout << 3 << “\n”;
for (ll i = 0; i < n - 1; i++)
cout << 1 + i % 2 << " ";
cout << 3 << “\n”;
}
else
{
for (ll i = 0; i < n; i++)
cout << 1 + i % 2 << " ";
cout << “\n”;
}
return;
}
set ans;
ll colors[n];
ll s = n;
while (t[s] ^ t[s - 1])
s–;
ll start = s, i = s, j;
while (true)
{
j = i;
while (t[j] != t[j + 1])
{
j++;
if(j%n == start - 1) break;
}
ll p = 0;
for (ll k = i; k <= j; k++)
{
colors[k % n] = 1 + p % 2;
p++;
}
j %= n;
i = j + 1;
if (i == start)
break;
}
for (ll i = 0; i < n; i++)
ans.insert(colors[i]);
cout << ans.size() << “\n”;
for (ll i = 0; i < n; i++)
cout << colors[i] << " ";
cout << “\n”;
}

int main()
{
ll q;
cin >> q;
while (q–)
{
ll n;
cin >> n;
ll t[2 * n];
for (ll i = 0; i < n; i++)
{
cin >> t[i];
t[i + n] = t[i];
}
solve(t, n);
}
return 0;
}