P1540(洛谷)
P1540 [NOIP2010 提高组] 机器翻译
以下是我的C++代码
#include <bits/stdtr1c++.h> //超级万能头文件
using std::cin;
using std::cout;
using std::endl; // 让cin,cout可视化
bool a[10001010];
int cnt = 0;
int b[10001010];
int main(void)
{
int n, m;
cin >> m >> n; // 不用用std了
int f = 0, r = 0; // 循环队列的对头和队尾
for(int i = 1; i <= n; i ++)
{
int x;
cin >> x;
if(a[x] == false)
{
cnt ++;
r ++;
b[r] = x;
a[x] = true;
if(r > m)
{
f ++;
a[b[f]] = false;
}
}
}
printf("%d\n", cnt);
return 0;
}
- 听说这道题木有测点是错误的~