제출 #1121445

#제출 시각아이디문제언어결과실행 시간메모리
1121445ezzzay아름다운 순열 (IZhO12_beauty)C++14
0 / 100
1 ms336 KiB
#include<bits/stdc++.h> using namespace std; #define ff first #define ss second #define pb push_back const int N=3e5+5; int a[N]; int bincnt(int n){ int p=0; while(n>0){ p+=n%2; n/=2; } return p; } int tercnt(int n){ int p=0; while(n>0){ if(n%3==1)p++; n/=3; } return p; } int bc[N],tc[N]; int dp[1048590][21]; signed main(){ int ans=0; int n; cin>>n; for(int i=0;i<n;i++){ cin>>a[i]; bc[i]=bincnt(a[i]); tc[i]=tercnt(a[i]); } for(int i=0;i<n;i++){ dp[(1<<i)][i]=1; } for(int i=1;i<(1<<n);i++){ for(int j=0;j<n;j++){ if((1<<j)&i ==0)continue; // suuld avsn for(int k=0;k<n;k++){ if((1<<k)&i==0 or k==j)continue; if(bc[j]==bc[k] or tc[j]==tc[k]){ dp[i][k]+=dp[i-(1<<k)][j]; } } if(i+1==(1<<n))ans+=dp[i][j]; } } cout<<ans; }

컴파일 시 표준 에러 (stderr) 메시지

beauty.cpp: In function 'int main()':
beauty.cpp:40:25: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   40 |             if((1<<j)&i ==0)continue; // suuld avsn
      |                       ~~^~~
beauty.cpp:42:28: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   42 |                 if((1<<k)&i==0 or k==j)continue;
      |                           ~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...