# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
521784 | aadit_ambadkar | Beautiful row (IZhO12_beauty) | C++11 | 3039 ms | 312 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*
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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |