답안 #493496

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
493496 2021-12-11T18:17:39 Z Homichki 아름다운 순열 (IZhO12_beauty) C++14
0 / 100
3000 ms 292 KB
#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);
        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

beauty.cpp: In function 'int main()':
beauty.cpp:24:8: warning: unused variable 'k' [-Wunused-variable]
   24 |     ll k,m,x1,y1,p,qqq,i,j,z,x,y,l,r,kry,w,sum,t,n,h,mew,ma,kol;
      |        ^
beauty.cpp:24:10: warning: unused variable 'm' [-Wunused-variable]
   24 |     ll k,m,x1,y1,p,qqq,i,j,z,x,y,l,r,kry,w,sum,t,n,h,mew,ma,kol;
      |          ^
beauty.cpp:24:12: warning: unused variable 'x1' [-Wunused-variable]
   24 |     ll k,m,x1,y1,p,qqq,i,j,z,x,y,l,r,kry,w,sum,t,n,h,mew,ma,kol;
      |            ^~
beauty.cpp:24:15: warning: unused variable 'y1' [-Wunused-variable]
   24 |     ll k,m,x1,y1,p,qqq,i,j,z,x,y,l,r,kry,w,sum,t,n,h,mew,ma,kol;
      |               ^~
beauty.cpp:24:18: warning: unused variable 'p' [-Wunused-variable]
   24 |     ll k,m,x1,y1,p,qqq,i,j,z,x,y,l,r,kry,w,sum,t,n,h,mew,ma,kol;
      |                  ^
beauty.cpp:24:20: warning: unused variable 'qqq' [-Wunused-variable]
   24 |     ll k,m,x1,y1,p,qqq,i,j,z,x,y,l,r,kry,w,sum,t,n,h,mew,ma,kol;
      |                    ^~~
beauty.cpp:24:26: warning: unused variable 'j' [-Wunused-variable]
   24 |     ll k,m,x1,y1,p,qqq,i,j,z,x,y,l,r,kry,w,sum,t,n,h,mew,ma,kol;
      |                          ^
beauty.cpp:24:28: warning: unused variable 'z' [-Wunused-variable]
   24 |     ll k,m,x1,y1,p,qqq,i,j,z,x,y,l,r,kry,w,sum,t,n,h,mew,ma,kol;
      |                            ^
beauty.cpp:24:42: warning: unused variable 'w' [-Wunused-variable]
   24 |     ll k,m,x1,y1,p,qqq,i,j,z,x,y,l,r,kry,w,sum,t,n,h,mew,ma,kol;
      |                                          ^
beauty.cpp:24:44: warning: unused variable 'sum' [-Wunused-variable]
   24 |     ll k,m,x1,y1,p,qqq,i,j,z,x,y,l,r,kry,w,sum,t,n,h,mew,ma,kol;
      |                                            ^~~
beauty.cpp:24:48: warning: unused variable 't' [-Wunused-variable]
   24 |     ll k,m,x1,y1,p,qqq,i,j,z,x,y,l,r,kry,w,sum,t,n,h,mew,ma,kol;
      |                                                ^
beauty.cpp:24:52: warning: unused variable 'h' [-Wunused-variable]
   24 |     ll k,m,x1,y1,p,qqq,i,j,z,x,y,l,r,kry,w,sum,t,n,h,mew,ma,kol;
      |                                                    ^
beauty.cpp:24:54: warning: unused variable 'mew' [-Wunused-variable]
   24 |     ll k,m,x1,y1,p,qqq,i,j,z,x,y,l,r,kry,w,sum,t,n,h,mew,ma,kol;
      |                                                      ^~~
beauty.cpp:24:58: warning: unused variable 'ma' [-Wunused-variable]
   24 |     ll k,m,x1,y1,p,qqq,i,j,z,x,y,l,r,kry,w,sum,t,n,h,mew,ma,kol;
      |                                                          ^~
beauty.cpp:27:10: warning: unused variable 's1' [-Wunused-variable]
   27 |     char s1;
      |          ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 204 ms 204 KB Output is correct
7 Correct 169 ms 292 KB Output is correct
8 Correct 638 ms 292 KB Output is correct
9 Correct 187 ms 288 KB Output is correct
10 Correct 1831 ms 288 KB Output is correct
11 Execution timed out 3063 ms 204 KB Time limit exceeded
12 Halted 0 ms 0 KB -