Submission #759328

# Submission time Handle Problem Language Result Execution time Memory
759328 2023-06-16T06:46:23 Z Unforgettablepl Beautiful row (IZhO12_beauty) C++17
0 / 100
156 ms 304 KB
/*
ID: samikgo1
TASK:
LANG: C++
*/
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
typedef pair<ll,ll> pll;
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define f first
#define s second
//#define x first
//#define y second
const int INF = INT32_MAX;
const ll modulo = 1e4;
//#define int ll

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.in","r",stdin);
//    freopen("haybales.out","w",stdout);
    ll n;
    cin >> n;
    vector<ll> arr(n);
    for(ll&i:arr)cin>>i;
    sort(all(arr));
    ll ans = 0;
    auto same = [](ll a, ll b){
        if(bitset<32>(a).count()==bitset<32>(b).count())return true;
        ll onesa = 0;
        ll onesb = 0;
        while(a or b){
            if(a%3==1)onesa++;
            if(b%3==1)onesb++;
            a/=3;b/=3;
        }
        return onesa==onesb;
    };
    do{
        for (ll i = 1; i < n; i++) {
            if(!same(arr[i],arr[i-1])){
                goto end;
            }
        }
        ans++;
        end:
        continue;
    }while(next_permutation(all(arr)));
    cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 145 ms 304 KB Output is correct
7 Correct 99 ms 296 KB Output is correct
8 Correct 156 ms 292 KB Output is correct
9 Incorrect 53 ms 292 KB Output isn't correct
10 Halted 0 ms 0 KB -