codeforces379a Alyona and mex
来源:互联网 发布:期权模拟交易软件 编辑:程序博客网 时间:2024/06/05 09:14
题意
给定一个n个数的序列和m个子序列,问没在m个子序列中出现过的可能的最大的数是多少(类似sg值),并输出任意一个符合要求的序列。
题目链接
思路
构造。。最大值取决于最短区间,只要保证最短区间是0 - len-1 即可,所以只要0-len-1循环即可。
代码
#include <stdio.h>#include <string.h>#include <queue>#include <algorithm>using namespace std;int n,m,a[101000];int main(){ scanf("%d%d",&n,&m); int l,r; int ans = 2e5; for(int i = 1;i <= m;i ++){ scanf("%d%d",&l,&r); ans = min(ans,r - l + 1); } int tmp = 0; for(int i = 1;i <= n;i ++){ a[i] = tmp%ans; tmp++; } printf("%d\n",ans); for(int i =1;i <= n;i ++){ printf("%d%c",a[i],i == n?'\n':' ' ); } return 0;}
0 0
- codeforces379a Alyona and mex
- Alyona and Mex
- B. Alyona and Mex
- codeforces739A. Alyona and mex
- codeforce B. Alyona and Mex
- C - Alyona and Mex CF682B
- Codeforces 358 . B Alyona and Mex
- CodeForces 682B Alyona and Mex
- CodeForces 682B Alyona and Mex
- Codeforces Round #381C. Alyona and mex
- Codeforces 739A Alyona and mex(构造)
- 【39.66%】【codeforces 740C】Alyona and mex
- Codeforces #381 C. Alyona and mex
- C. Alyona and mex--思维水题
- CodeForces 740C - Alyona and mex(思维)
- 740C.Alyona and mex codeforces
- CodeForces 682B Alyona and Mex
- Codeforces Round #358 (Div. 2) B. Alyona and Mex
- 腾讯投资在行&分答,探索分享经济下的未来社交模式
- PAT(basic level) 1028 人口普查(20)
- MFC单文档去掉默认的菜单、工具栏和状态栏
- A Brief Introduction of Deep Learning
- Android7.0适配心得
- codeforces379a Alyona and mex
- 四连杆运动仿真
- 放苹果
- C语言模拟单向链表
- caffe学习笔记(1)--配置及导入自己的数据
- 漫谈继承技术(七)
- React native和原生之间的通信
- 检测输入的字符是否为“g”
- MySQL及数据库设计小结