QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#680737#8332. Two in OneIcyechoCompile Error//C++17668b2024-10-26 22:25:282024-10-26 22:25:29

Judging History

你现在查看的是最新测评结果

  • [2024-10-26 22:25:29]
  • 评测
  • [2024-10-26 22:25:28]
  • 提交

answer

#include<bits/stdc++.h>
#include<vector>
using namespace std;

typedef long long ll;
const int N = 100005;

int a[N];
int ct[N];

void solve() {
	int n;
	cin >> n;	
	vector<int> c(n);


	for (int i = 1; i <= n; i++) {
		int x;
		cin >> x;
		ct[x]++;
		c[x - 1]++;
	}
	if (n == 1) {
		cout << c[0] << '\n';
		return;
	}
	sort(c.begin(), c.end());
	int ans = c[n - 1] | c[n - 2] | ;
	int now = ((1 << (__lg(c[n - 1] & c[n - 2]))) - 1);
	if (now < 0) now = 0;
	ans |= now;
	cout << ans  << '\n';

}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int T;
	cin >> T;
	while(T--) {
		solve();
	}


	return 0;
}

Details

answer.code: In function ‘void solve()’:
answer.code:28:41: error: expected primary-expression before ‘;’ token
   28 |         int ans = c[n - 1] | c[n - 2] | ;
      |                                         ^