Submission #90109

#TimeUsernameProblemLanguageResultExecution timeMemory
90109YottaByteBeautiful row (IZhO12_beauty)C++14
0 / 100
303 ms704 KiB
#include <bits/stdc++.h> using namespace std; const int N = 20; int a[N + 1], n, ans; inline bool count(int a, int b) { int resa, resb; resa = resb = 0; while(a) { resa += (a % 3 == 1); a /= 3; } while(b) { resb += (b % 3 == 1); b /= 3; } return (resa == resb); } inline bool check() { int c = 0; for(int i = 1; i < n; i++) { if(__builtin_popcount(a[i]) == __builtin_popcount(a[i + 1])) c++; else if(count(a[i], a[i + 1])) c++; else return false; } return true; } void out() { for(int i = 1; i <= n; i++) { cout << a[i] << " "; } } main() { cin >> n; for(int i = 1; i <= n; i++) { cin >> a[i]; } sort(a + 1, a + 1 + n); do { if(check()) ans++; } while(next_permutation(a + 1, a + 1 + n)); cout << ans << endl; }

Compilation message (stderr)

beauty.cpp:46:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
#Verdict Execution timeMemoryGrader output
Fetching results...