Submission #521784

#TimeUsernameProblemLanguageResultExecution timeMemory
521784aadit_ambadkarBeautiful row (IZhO12_beauty)C++11
0 / 100
3039 ms312 KiB
/* This code belongs to Aadit Ambadkar Date: 2022-02-02 21:55:57 Problem: br */ #include <bits/stdc++.h> using namespace::std; typedef long long ll; #define F0R(i, n) for (int i = 0; i < n; i++) #define R0F(i, n) for (int i = n-1; i >= 0; i--) #define FOR(i, a, n) for (int i = a; i < n; i++) #define pb push_back #define fastio ios::sync_with_stdio(0); cin.tie(0) #define MOD 1000000007 #define FF first #define SS second int bcount(int n) { int ans = 0; while (n) { if (n%2==1) ans++; n/=2; } return ans; } int tcount(int n) { int ans = 0; while (n) { if (n%3==1) ans++; n/=3; } return ans; } int n; vector<int> arr; vector<int> bc; vector<int> tc; int main() { fastio; cin >> n; F0R(i, n) { int x; cin >> x; arr.pb(x); bc.pb(bcount(x)); tc.pb(tcount(x)); } // F0R(i, n) { // cout << bc[i] << " "; // } // cout << "\n"; // F0R(i, n) { // cout << tc[i] << " "; // } // cout << "\n"; vector<int> ord; F0R(i, n) { ord.pb(i); } int ans = 0; do { bool flag = true; F0R(i, n-1) { if (bc[ord[i]]!=bc[ord[i+1]] && tc[ord[i]]!=tc[ord[i+1]]) { flag = false; break; } } if (flag) { ans++; } } while (next_permutation(ord.begin(), ord.end())); cout << ans << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...