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]之间,并且数组全 ...
随机推荐
- Arduino Uno 在win7 64位下的驱动问题
1.解压[mdmcpq.inf_amd64_neutral_fbc4a14a6a13d0c8.rar],将[mdmcpq.inf_amd64_neutral_fbc4a14a6a13d0c8]文件夹复 ...
- Unity3d 脚本与C#Socket服务器传输数据
Test.cs脚本 ------------------------------------------------------------------------------------------ ...
- 适合新手的Python爬虫小程序
介绍:此程序是使用python做的一个爬虫小程序 爬取了python百度百科中的部分内容,因为这个demo是根据网站中的静态结构爬取的,所以如果百度百科词条的html结构发生变化 需要修改部分内容. ...
- 第四章输入/输出(I/O)4.1I/O涉及的设备及相关概念简介
PCL中所有的处理都是基于点云展开的,利用不同的设备获取点云.存储点云等都是点云处理前后必须做的流程,PCL中有自己设计的内部PCD文件格式,为此,设计读写该该格式以及与其他3D文件格式之间进行转化的 ...
- Python程序设计8——网络编程
Python是一个很强大的网络编程工具,python内有很多针对场景网络协议的库,在库顶部可以获得抽象层,这样就可以集中精力在程序的逻辑处理上,而不是停留在网络实现的细节中. 1 少数几个网络设计模块 ...
- 操作系统 Linux ex1 note
ctrl + alt + T 命令行 ctrl + alt + F7 ctrl + alt + F1-6 ls 列出所有文件 / 根目录 ~ /home/username cd 切换路径 . 当前目录 ...
- LeetCode第70题:爬楼梯
问题描述 假设你正在爬楼梯.需要 n 阶你才能到达楼顶. 每次你可以爬 1 或 2 个台阶.你有多少种不同的方法可以爬到楼顶呢? 注意:给定 n 是一个正整数. 示例 1: 输入: 2 输出: 2 解 ...
- Spring学习大纲
1.BeanFactory 和 FactoryBean? 2.Spring IOC 的理解,其初始化过程? 3.BeanFactory 和 ApplicationContext? 4.Spring B ...
- js/jq基础(日常整理记录)-2-一个简单的js方法实现集合的非引用拷贝
一.一个简单的js方法实现集合拷贝 做web项目的时候,少不了和js中的数组,集合等对象接触,那么你肯定会发现,在js中存在一个怪异的现象就是数组和集合的拷贝都是地址复制,并不是简单的数据的拷贝. 举 ...
- yzm10的小简介
yzm10,退役OIer,现役ACMer.大学生一枚,从高中开始接触编程(入门pascal...),过程基本自学,蒟蒻一只,在各大比赛划水打酱油..15年水得noip联二后退役,结束OI之旅.也是在1 ...