# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
493493 | Homichki | Beautiful row (IZhO12_beauty) | C++14 | 665 ms | 308 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll st3(ll x)
{
ll kol=0;
while(x>0)
{
if(x%3==1)
{
kol++;
}
x/=3;
}
return kol;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
//ifstream cin("input.txt");
//ofstream cout("output.txt");
ll k,m,x1,y1,p,qqq,i,j,z,x,y,l,r,kry,w,sum,t,n,h,mew,ma,kol;
vector<ll> a,b;
string s;
char s1;
cin>>n;
for(i=0;i<n;i++)
{
cin>>x;
a.push_back(x);
}
sort(a.begin(),a.end());
kol=0;
do
{
kry=0;
for(i=1;i<n;i++)
{
y=__builtin_popcount(a[i-1]);
x=__builtin_popcount(a[i]);
l=st3(a[i-1]);
r=st3(a[i]);
if((y!=x) && (l!=r))
{
kry++;
break;
}
}
if(kry==0)
{
kol++;
}
}while(next_permutation(a.begin(),a.end()));
cout<<kol;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |