| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 881109 | alexdd | 아름다운 순열 (IZhO12_beauty) | C++17 | 3048 ms | 348 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... | ||||
