Codeforces Round #532 (Div. 2)- B(思维)
Arkady coordinates rounds on some not really famous competitive programming platform. Each round features nn problems of distinct difficulty, the difficulties are numbered from 11 to nn.
To hold a round Arkady needs nn new (not used previously) problems, one for each difficulty. As for now, Arkady creates all the problems himself, but unfortunately, he can't just create a problem of a desired difficulty. Instead, when he creates a problem, he evaluates its difficulty from 11 to nn and puts it into the problems pool.
At each moment when Arkady can choose a set of nn new problems of distinct difficulties from the pool, he holds a round with these problems and removes them from the pool. Arkady always creates one problem at a time, so if he can hold a round after creating a problem, he immediately does it.
You are given a sequence of problems' difficulties in the order Arkady created them. For each problem, determine whether Arkady held the round right after creating this problem, or not. Initially the problems pool is empty.
Input
The first line contains two integers nn and mm (1≤n,m≤1051≤n,m≤105) — the number of difficulty levels and the number of problems Arkady created.
The second line contains mm integers a1,a2,…,ama1,a2,…,am (1≤ai≤n1≤ai≤n) — the problems' difficulties in the order Arkady created them.
Output
Print a line containing mm digits. The ii-th digit should be 11 if Arkady held the round after creation of the ii-th problem, and 00 otherwise.
Examples
input
Copy
3 11
2 3 1 2 2 2 3 2 2 3 1
output
Copy
00100000001
input
Copy
4 8
4 1 3 3 2 3 3 3
output
Copy
00001000
Note
In the first example Arkady held the round after the first three problems, because they are of distinct difficulties, and then only after the last problem.
思路:一开始理解错题意了,以前剩下的题目也要算在后边,故可以用标记数组的量来检测
代码:
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int vis[100005],a[100005];
int main()
{
int n,m;
cin>>n>>m;
int sum=0;
for(int t=0;t<m;t++)
{
scanf("%d",&a[t]);
if(vis[a[t]]==0)
{
sum++;
}
vis[a[t]]++;
if(sum==n)
{
printf("1");
sum=0;
for(int j=1;j<=n;j++)
{
vis[j]--;
if(vis[j]>0)
{
sum++;
}
}
}
else if(sum<n)
{
printf("0");
}
}
return 0;
}
Codeforces Round #532 (Div. 2)- B(思维)的更多相关文章
- Codeforces Round #532 (Div. 2)
Codeforces Round #532 (Div. 2) A - Roman and Browser #include<bits/stdc++.h> #include<iostr ...
- Codeforces Round #532 (Div. 2) 题解
Codeforces Round #532 (Div. 2) 题目总链接:https://codeforces.com/contest/1100 A. Roman and Browser 题意: 给出 ...
- Codeforces Round #532 (Div. 2)- A(思维)
This morning, Roman woke up and opened the browser with nn opened tabs numbered from 11 to nn. There ...
- 【CF1256】Codeforces Round #598 (Div. 3) 【思维+贪心+DP】
https://codeforces.com/contest/1256 A:Payment Without Change[思维] 题意:给你a个价值n的物品和b个价值1的物品,问是否存在取物方案使得价 ...
- Codeforces Round #143 (Div. 2) (ABCD 思维场)
题目连链接:http://codeforces.com/contest/231 A. Team time limit per test:2 seconds memory limit per test: ...
- Codeforces Round #395 (Div. 2)(A.思维,B,水)
A. Taymyr is calling you time limit per test:1 second memory limit per test:256 megabytes input:stan ...
- Codeforces Round #416 (Div. 2)(A,思维题,暴力,B,思维题,暴力)
A. Vladik and Courtesy time limit per test:2 seconds memory limit per test:256 megabytes input:stand ...
- Codeforces Round #532 (Div. 2) F 线性基(新坑) + 贪心 + 离线处理
https://codeforces.com/contest/1100/problem/F 题意 一个有n个数组c[],q次询问,每次询问一个区间的子集最大异或和 题解 单问区间子集最大异或和,线性基 ...
- Codeforces Round #533 (Div. 2) C.思维dp D. 多源BFS
题目链接:https://codeforces.com/contest/1105 C. Ayoub and Lost Array 题目大意:一个长度为n的数组,数组的元素都在[L,R]之间,并且数组全 ...
随机推荐
- Spring装配各种类型bean
一.单属性值的装配 //setter注入,提供无参构造器,提供setXX方法 <property name="" value=""></pro ...
- 【262】pscp命令 实现windows与linux互传文件
首先将pscp.exe文件放在某个文件夹中 新建*.bat文件 w-wx.bat代码 @echo off pscp.exe -pw l*****h D:\Windows-Linux\Data\* oc ...
- 自定义Android Studio方法注释模板
前言 你们从Eclipse转到Android Studio的时候,是不是会怀念Eclipse的方法注释模版? 敲/**加回车,模板就出来了,而Android Studio却不能自定义(或者我没有找到) ...
- android opencv
最近工作需求:用opencv来先做一个demo.扫描照片进行边缘检测和透视矫正. 之后会加入照片降噪等处理. 请教了一下搞图像的同事.他的提议: 1.绿盟的“黄色照片检测” 用的是动态的opencv库 ...
- sqlplus--sqlldr基础运用
a.ctl load data infile * ...
- [Elasticsearch2.x] 多字段搜索 (三) - multi_match查询和多数字段 <译>
multi_match查询 multi_match查询提供了一个简便的方法用来对多个字段执行相同的查询. NOTE 存在几种类型的multi_match查询,其中的3种正好和在“了解你的数据”一节中提 ...
- IFC—IfcProduct实体继承框架
- PCL—关键点检测(NARF)低层次点云处理
博客转载自:http://www.cnblogs.com/ironstark/p/5051533.html 关键点检测本质上来说,并不是一个独立的部分,它往往和特征描述联系在一起,再将特征描述和识别. ...
- WarTransportation TopCoder - 8404
传送门 分析 我们高兴的发现数据范围特别小,所以我们可以随便搞.因为一共只砍掉一条路,所以我们先算出对于任意一个点如果将它的出边割掉一条则它到达终点的最坏情况的最短距离是多少,然后我们从终点向起点反着 ...
- Luogu 2939 [USACO09FEB]改造路Revamping Trails && Luogu 4568 [JLOI2011]飞行路线
双倍经验 写这两题之前被大佬剧透了呜呜呜. 分层图+最短路. 因为有$k$次机会能够把路径的费用变为$0$,我们可以建$k + 1$层图,对于每一层图我们把原来的边权和双向边连到上面去,而对于层与层之 ...