QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#234668#5543. The Only Modedmmm#WA 0ms3688kbC++171.0kb2023-11-01 20:39:022023-11-01 20:39:02

Judging History

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

  • [2023-11-01 20:39:02]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3688kb
  • [2023-11-01 20:39:02]
  • 提交

answer

	#include<bits/stdc++.h>
	using namespace std;
	#define int long long 
	const int MAXN = 1e5 + 6.9;
	const int INF = 1e18;
	int n;
	int a[MAXN];
	int pre[MAXN];
	int num[MAXN][4];
	int check(int len, int val) {
		for (int i = 1; i + len - 1 <= n; i++) {
			int cnt = num[i + len - 1][val] - num[i - 1][val];
			int ok = 1;
			for (int j = 0; j < 4; j++) {
				if (j == val) continue;
				if (cnt <= num[i + len - 1][j] - num[i - 1][j]) ok = 0;
			}
			if (ok) return 1;
		}
		return 0;
	}
	int bin(int l, int r, int val) {
		while (l < r) {
			int mid = (l + r) / 2 + 1;
			if (check(mid, val)) {
				l = mid;
			}
			else {
				r = mid - 1;
			}
		}
		return l;
	}
	void solve(int val) {
		cout << bin(0, n, val) << ' ';
	}
	signed main() {
		ios::sync_with_stdio(0);
		cin.tie(0); cout.tie(0);
		cin >> n;
		for (int i = 1; i <= n; i++) cin >> a[i];
		for (int i = 1; i <= n; i++) {
			for (int j = 0; j < 4; j++) num[i][j] = num[i - 1][j];
			num[i][a[i]]++;
		}
		for (int i = 0; i < 4; i++) solve(i);
	}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3688kb

input:

7
1 2 2 0 3 0 3

output:

4 1 5 1 

result:

wrong answer 1st lines differ - expected: '4 1 5 3', found: '4 1 5 1 '