Submission #503052

# Submission time Handle Problem Language Result Execution time Memory
503052 2022-01-07T04:36:50 Z ismoilov Beautiful row (IZhO12_beauty) C++14
0 / 100
0 ms 204 KB
#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

beauty.cpp: In function 'int tr(int, bool)':
beauty.cpp:6:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    6 | #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
      |                           ^
beauty.cpp:22:2: note: in expansion of macro 'fp'
   22 |  fp(i,0,s.size())
      |  ^~
beauty.cpp:6:42: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    6 | #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
      |                                      ~~~~^~~~~
beauty.cpp:22:2: note: in expansion of macro 'fp'
   22 |  fp(i,0,s.size())
      |  ^~
beauty.cpp: In function 'void S()':
beauty.cpp:6:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    6 | #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
      |                           ^
beauty.cpp:32:2: note: in expansion of macro 'fp'
   32 |  fp(i,0,n)
      |  ^~
beauty.cpp:6:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    6 | #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
      |                           ^
beauty.cpp:35:2: note: in expansion of macro 'fp'
   35 |  fp(i,0,n){
      |  ^~
beauty.cpp:6:27: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
    6 | #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
      |                           ^
beauty.cpp:36:3: note: in expansion of macro 'fp'
   36 |   fp(j,i+1,n){
      |   ^~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -