Submission #173199

#TimeUsernameProblemLanguageResultExecution timeMemory
173199juggernautBeautiful row (IZhO12_beauty)C++14
100 / 100
1660 ms164500 KiB
//Just try and the idea will come! #include<bits/stdc++.h> #define int long long int using namespace std; int n,i,a[20],dp[1048576][20],ans,j,tri[20],bin[20],mask; main(){ scanf("%lld",&n); for(;i<n;i++){ scanf("%lld",&a[i]); dp[1<<i][i]=1; bin[i]=__builtin_popcount(a[i]); mask=a[i]; while(mask){ if(mask%3==1)tri[i]++; mask/=3; } } for(mask=0;mask<(1<<n);mask++) for(i=0;i<n;i++) if(mask&(1<<i)) for(j=0;j<n;j++) if(i!=j) if(mask&(1<<j)&&(tri[i]==tri[j]||bin[i]==bin[j]))dp[mask][i]+=dp[mask^(1<<i)][j]; for(i=0;i<n;i++)ans+=dp[(1<<n)-1][i]; printf("%lld",ans); }

Compilation message (stderr)

beauty.cpp:6:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
beauty.cpp: In function 'int main()':
beauty.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld",&n);
     ~~~~~^~~~~~~~~~~
beauty.cpp:9:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld",&a[i]);
         ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...