ULSG T3 0pts 求调
  • 板块学术版
  • 楼主rainygame
  • 当前回复5
  • 已保存回复5
  • 发布时间2023/6/11 19:32
  • 上次更新2023/10/23 13:20:41
查看原帖
ULSG T3 0pts 求调
804607
rainygame楼主2023/6/11 19:32
#include <bits/stdc++.h>
using namespace std;
#define MAXN 600001

int n, m, k;
int a[MAXN], b[17], c[MAXN][17];
queue<pair<int, int>> que;

bool check(int x){
	int cnt(0);
	for (int i(1); i<=16; ++i){
		if (c[x+m][i]-c[x][i] != b[i]) ++cnt;
	}
	return cnt <= k;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin >> n >> m >> k;
	for (int i(1); i<=n; ++i){
		cin >> a[i];
		memcpy(c[i], c[i-1], sizeof(c[i]));
		if (a[i]) ++c[i][a[i]];
	}
	for (int i(1); i<=16; ++i) cin >> b[i];
	
	for (int i(1); i+m-1<=n; ++i){
		if (check(i-1)) que.push(make_pair(i, i+m-1));
	}
	
	cout << que.size() << '\n';
	while (!que.empty()){
		cout << que.front().first << ' ' << que.front().second << '\n';
		que.pop();
	}
	
	return 0;
}

思路就是前缀和

2023/6/11 19:32
加载中...