Submission #885768

#TimeUsernameProblemLanguageResultExecution timeMemory
885768ZeroBeautiful row (IZhO12_beauty)C++17
0 / 100
540 ms600 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int bt(int n){ return __builtin_popcountll(n); } int tr(int n){ int y = 0; while(n){ if(n%3==1) y++; n/=3; } return y; } bool ok(vector<int> a){ for(int i=0; i < a.size()-1; i ++){ int b1 = bt(a[i]), t1 = tr(a[i]); int b2 = bt(a[i+1]), t2 = tr(a[i+1]); if(!(b1 == b2 || t1 == t2)) return 0; } return 1; } signed main() { int n; cin >> n; vector<int> a(n); int z = 0; for(auto &i : a ){ cin >> i; if(!i)z++; } if(z) return cout << 0,0; sort(a.begin(),a.end()); int c = 0; do{ c += ok(a); }while(next_permutation(a.begin(),a.end())); cout << c; return 0; }

Compilation message (stderr)

beauty.cpp: In function 'bool ok(std::vector<long long int>)':
beauty.cpp:16:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |  for(int i=0; i < a.size()-1; i ++){
      |               ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...