# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
881109 | alexdd | Beautiful row (IZhO12_beauty) | C++17 | 3048 ms | 348 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<iostream>
#include<algorithm>
using namespace std;
int n;
pair<pair<int,int>,pair<int,int>> a[25];
int calc_cnt2(int x)
{
int rez=0;
for(int i=0;i<30;i++)
{
if(((1<<i)&x))
rez++;
}
return rez;
}
int calc_cnt3(int x)
{
int rez=0;
while(x>0)
{
if(x%3==1)
rez++;
x/=3;
}
return rez;
}
signed main()
{
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i].second.first;
a[i].first = {calc_cnt2(a[i].second.first), calc_cnt3(a[i].second.first)};
a[i].second.second=i;
}
sort(a+1,a+1+n);
long long rez=0;
do
{
rez++;
for(int i=1;i<n;i++)
{
if(a[i].first.first!=a[i+1].first.first && a[i].first.second!=a[i+1].first.second)
{
rez--;
break;
}
}
}while(next_permutation(a+1,a+1+n));
cout<<rez;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |