| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 493497 | Homichki | 아름다운 순열 (IZhO12_beauty) | C++14 | 1738 ms | 324 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;
    if(n>10)
    {
        return 0;
    }
    for(i=0;i<n;i++)
    {
        cin>>x;
        a.push_back(x);
        b.push_back(i);
    }
    sort(b.begin(),b.end());
    kol=0;
    do
    {
        kry=0;
        for(i=1;i<n;i++)
        {
            y=__builtin_popcount(a[b[i-1]]);
            x=__builtin_popcount(a[b[i]]);
            l=st3(a[b[i-1]]);
            r=st3(a[b[i]]);
            if((y!=x) && (l!=r))
            {
                kry++;
                break;
            }
        }
        if(kry==0)
        {
            kol++;
        }
    }while(next_permutation(b.begin(),b.end()));
    cout<<kol;
    return 0;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
