社区讨论

求助,30分

P1540[NOIP 2010 提高组] 机器翻译参与者 4已保存回复 5

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
5 条
当前快照
1 份
快照标识符
@mi86heut
此快照首次捕获于
2025/11/21 09:25
4 个月前
此快照最后确认于
2025/11/21 09:25
4 个月前
查看原帖
CPP
#include <bits/stdc++.h>
using namespace std;

int m, n;
int q[1005];
int front, rear, total;
bool v[1005], cover;

int main()
{
	cin >> m >> n;
	if(m == 0){
		cout << n;
		return 0;
	}
	for(int i = 0, x; i < n; i++)
	{
		if(rear >= m){
			rear = 0;
			cover = true;
		}
		if(front >= m){
			front = 0;
		}
		cin >> x;
		q[i] = x;
//		cerr << v[x] << endl;
		if(!v[x]){
			if(cover) v[q[i-m]] = false;
			total++;
			v[x] = true;
			rear++;
		}
		else{
			continue;
		}
//		for(int j = 0; j <= 5; j++){
//			cerr << (v[j] == true ? j : -1) << " ";
//		}
//		puts("");
	}
	cout << total; 
	return 0;
}

回复

5 条回复,欢迎继续交流。

正在加载回复...