# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
503052 | ismoilov | Beautiful row (IZhO12_beauty) | C++14 | 0 ms | 204 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.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
#define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++)
#define fm(a,i,c) for(int (a) = (i); (a) > (c); (a)--)
#define fmm(a,i,c) for(int (a) = (i); (a) >= (c); (a)--)
string s = "";
void tr(int n){
if(n < 3){
s = to_string(n) + s;
return;
}
s = to_string(n % 3) + s;
tr(n/3);
}
int tr(int n, bool ok){
tr(n);
int sz = 0;
fp(i,0,s.size())
sz += (s[i] == '1');
s = "";
return sz;
}
void S()
{
int n;
cin >> n;
vector <int> a(n);
fp(i,0,n)
cin >> a[i];
ll ans = 0;
fp(i,0,n){
fp(j,i+1,n){
if(__builtin_popcount(a[i]) == __builtin_popcount(a[j]) || tr(a[i], 0) == tr(a[j], 0))
ans ++;//, cout << a[i] << " " << a[j] << "\n";
//cout << a[i] << " " << a[j] << " " << tr(a[i], 0) << " " << tr(a[j], 0) << "\n";
}
}
cout << ans;
}
int main()
{
IOS;
S();
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |