QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#553557#8332. Two in OneMax_FWLWA 1ms4028kbC++141.1kb2024-09-08 15:25:292024-09-08 15:25:30

Judging History

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

  • [2024-09-08 15:25:30]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:4028kb
  • [2024-09-08 15:25:29]
  • 提交

answer

#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

typedef pair<int, int> pii;
const int N = 1e5 + 10;
int T, n, ans, c1, c2, a[N], box[N];
vector<int> vec;
pii u[N];

bool CMP(pii x, pii y){
	return x.fi > y.fi;
}

void Solve(){
	ans = -1;
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	
	for (int i = 1; i <= n; i++)
		box[i] = 0;
	for (int i = 1; i <= n; i++)
		box[a[i]]++;
	for (int i = 1; i <= n; i++)
		u[i] = make_pair(box[i], i);
	
	sort(u + 1, u + n + 1, CMP);
	int v = u[1].fi, res = 0;
	for (int i = 19; i >= 0; i--){
		if (v & (1 << i))
			continue;
		if (res + (1 << i) <= u[2].fi)
			res += (1 << i);
	}
		
	cout << (v | res) << endl;
	c1 = u[1].se;
	c2 = u[2].se;
	
	cout << 1 << " " ;
	memset(box, 0, sizeof(box));
	for (int i = 1; i <= n; i++){
		box[a[i]]++;
		if ((box[c1] | box[c2]) == (v | res)){
			cout << i << endl;
			cout << c1 << " " << c2 << endl;
			break;
		}
	}
}

signed main(){
	//freopen("ttheal.in", "r", stdin);
	//freopen("ttheal.out", "w", stdout);
	cin >> T;
	
	while (T--)
		Solve();
	
	return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 4028kb

input:

1
7
1 2 3 4 3 2 1

output:

3
1 6
1 2

result:

wrong answer Output contains longer sequence [length = 5], but answer contains 1 elements